// address = 0x27
#include <Wire.h>
void setup()
{ // put your setup code here, to run once:
Wire.begin();
Serial.begin(9600);
Serial.println("\nI2C Scanner");
}
void loop()
{
// put your main code here, to run repeatedly:
byte error, address;
int Devices;
Serial.println("Scanning...");
Devices = 0;
for (address = 1; address < 123; 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(" !");
Devices++;
}
else if (error == 4)
{
Serial.print("Unknown error at address 0x");
if (address < 16)
Serial.print("0");
Serial.print(address, HEX);
}
}
if (Devices == 0)
{
Serial.println("No I2C device found\n");
}
else
{
Serial.println("done\n");
}
delay(5000);
}
//20BCE198 Part 2
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// 5x7
byte k[] = {B01110, B10000, B10010, B01110, B01001, B00001, B10001, B01110};
byte m[] = {B11100, B00100, B00100, B11111, B10100, B10100, B11100, B00000};
byte p[] = {B11000, B01000, B01000, B01000, B01111, B00000, B00000, B00000};
byte u[] = {B11010, B01010, B01010, B11010, B10010, B01110, B00011, B11111};
byte r[] = {B11111, B10001, B00010, B00100, B11000, B00100, B00010, B00011};
byte t[] = {B11110, B10001, B00001, B01111, B10000, B10000, B10001, B01111};
void setup()
{
lcd.init();
Serial.begin(9600);
lcd.backlight();
lcd.createChar(1, k);
lcd.createChar(2, m);
lcd.createChar(3, p);
lcd.createChar(4, u);
lcd.createChar(5, t);
lcd.createChar(6, r);
lcd.setCursor(0, 0);
lcd.write(byte(1));
lcd.write(byte(2));
lcd.write(byte(3));
lcd.write(byte(4));
lcd.write(byte(5));
lcd.write(byte(6));
}
void loop()
{
}