完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在设备(安装在 LCM1602 上的 PCF8574T)的数据表上,地址是 0100 1110=4E 但程序仍然没有在 LCD 上显示任何字母。哪里错了?我检查了很多次别针,他们是对的。在 Cube IDE 上也一样。
|
|
相关推荐
1个回答
|
|
i2c_scanner Last Modified: November 14, 2018, at 09:21 AM By: This very simple sketch scans the I2C-bus for devices. If a device is found, it is reported to the Arduino serial monitor. This sketch is the first step to get the I2C communication working. The sketch shows the 7-bit addresses of the found devices as hexadecimal values. That value can be used for the "Wire.begin" function which uses the 7-bit address. Some datasheets use the 8-bit address and some example sketches use decimal addresses. Interesting links The Arduino Wire Reference. I2C Bi-directional Level Shifter about level shifting, pull-up resistors and connecting 3.3V devices. Nick Gammon's page about I2C : (the page also has a "I2C Scanner"). robtillaart made a "Multispeed I2C Scanner" that scans with different I2C speeds. If you use longer wires or libraries that use higher I2C speeds, the Multispeed I2C Scanner is very useful. (verified with UNO, 2009, MEGA) Sketch Open a new sketch and copy the sketch below into it. Upload it to the Arduino and open the serial monitor. Every found device on the I2C-bus is reported. You can change the wires, and plug-in I2C devices while the i2c_scanner is running. The output of the serial monitor will look like this: Please do not change the sketch. If you have improvements, add your improved sketch to this page. // -------------------------------------- // i2c_scanner // // Version 1 // This program (or code that looks like it) // can be found in many places. // For example on the Arduino.cc forum. // The original author is not know. // Version 2, Juni 2012, Using Arduino 1.0.1 // Adapted to be as simple as possible by Arduino.cc user Krodal // Version 3, Feb 26 2013 // V3 by louarnold // Version 4, March 3, 2013, Using Arduino 1.0.3 // by Arduino.cc user Krodal. // Changes by louarnold removed. // Scanning addresses changed from 0...127 to 1...119, // according to the i2c scanner by Nick Gammon // // Version 5, March 28, 2013 // As version 4, but address scans now to 127. // A sensor seems to use address 120. // Version 6, November 27, 2015. // Added waiting for the Leonardo serial communication. // // // This sketch tests the standard 7-bit addresses // Devices with higher bit address might not be seen properly. // #include void setup() { Wire.begin(); Serial.begin(9600); while (!Serial); // Leonardo: wait for serial monitor Serial.println("nI2C Scanner"); } void loop() { byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 0; for(address = 1; address < 127; address++ ) { // The i2c_scanner uses the return value of // the Write.endTransmisstion to see if // a device did acknowledge to the address. Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address<16) Serial.print("0"); Serial.print(address,HEX); Serial.println(" !"); nDevices++; } else if (error==4) { Serial.print("Unknown error at address 0x"); if (address<16) Serial.print("0"); Serial.println(address,HEX); } } if (nDevices == 0) Serial.println("No I2C devices foundn"); else Serial.println("donen"); delay(5000); // wait 5 seconds for next scan } 是指向 I2C 扫描仪的链接。
|
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2599 浏览 1 评论
3200 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1774 浏览 1 评论
3597 浏览 6 评论
5978 浏览 21 评论
928浏览 4评论
1305浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
573浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1292浏览 3评论
1346浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-14 21:25 , Processed in 1.116964 second(s), Total 81, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号