This return value store the value to the variable "error". The i2c_scanner uses the return value of the "Write.endTransmisstion()" to see if a device did acknowledge to the address. Next input the address to wire with the function "Wire.beginTransmission()". Next start a for loop with minimum value of 1 and maximum of 127. Then define another variable with the "Integer ( int)" datatype named as "Devices". Next in loop part, define two variables with the datatype "byte" named "error" and "address". Then begin the serial monitor as the baud rate of 9600 by "Serial.begin()". Then in setup part, begin the "Wire" library by "Wire.begin()". First add the header file for include "Wire.h" library. I2C Scanner code is used for find the number of I2C devices and address of I2C devices. For that we need to run the Arduino with "I2C Scanner" code. So we need to find the original address of that device. In some cases A0, A1, A2 are "Not connected" state, but the address is not 0x27. Step -1 Skip this Step - 1 & Step -2 if you already know the address of the LCD For more address see the table given below. Because two or more different device can't communicate with the same address. But when we use more than one LCD, need to change the address. There is no need to change the address of the I2C module when we use only one LCD. In default the A0, A1, A2 are in "Not connected" condition. When A0, A1, A2 are in "Not Connected" condition ( A0 = 0, A1 = 0, A2 = 0) the address would be 0x27. if, there is a connection between upper potion with lower connection it is called " Connected " otherwise it is called " Not connected ". ie, each solder pads have one upper potion and a one lower potion. You can see three solder pads on the I2C module. We need to know this address for communicate with that particular device. Every device which can attached to MCU have an address. When we remove the jumber, the backlight of the LCD display will go OFF.īefore starting we need to know about addressing of I2C devices. And there is a jumber fixed on the module. We can control the contrast of the LCD display by rotating this POT. The rest 2 pins for power supply (Vcc and ground).There is a POT on the I2C Module. SDA is the serial data pin and SCL is the clock pin. The 16 pins for connect to 16x2 LCD and the 2 pins out of 4 pins are SDA and SCL. 16 pins are faced to rear side and 4 pins faced towards front side.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |