// i2c_scanner display on serial & parallel LCD // & also PCF8574 i2c LCD // // For R909OLED PCB with lcd(8,9,10,11,12.13); @20231029 // #define lcd_backlight 7 // // LCD&i2c connection OK serial OK // // Expecting address Si5351a:0x60, Si4732:0x63(0x11), i2c LCD:0x27 // OLED:0x3C // // Added PCF8574 type 2021.11.15 // Delete LCD #include // 0x3E Akiduki LCD // // SCL:A5,SDA:A4 // 20200711 ok // // Version 5, March 28, 2013 // Cover over 7-bit(127d), not handle extention address // #include // #include /* ChibiDuino2 LCD sample * SETUP: (Hitachi HD44780 compatable LCD) * +5V LCD Vdd pin 2 >>> Gnd LCD Vss pin 1, and R/W pin 5 * LCD RS pin 4 to D5 >>> LCD Enable pin 6 to D6 * LCD D4 pin 11 to D9 >>> LCD D5 pin 12 to D10 * LCD D6 pin 13 to D11 >>> LCD D7 pin 14 to D12 * 10K pot: - ends to +5V and Gnd, wiper to LCD VO pin (pin 3) */ //Akiduki i2c lcd #include // Sure 8x2 LCD works with this lib //Akiduki lcd instance // skI2CLCDlib LCD(0x3E, 16); // Akiduki LCD i2c addess 16 chars per 2 lines // PCF8574 i2c lcd instance // Thanks for giving information about i2c LCD adapter // https://github.com/marcoschwartz/LiquidCrystal_I2C #include LiquidCrystal_I2C lcdi2c(0x27,16,2); // Parallel LCD for Adru5351 PCB // instanciate the library and pass pins for (RS, Enable, D4, D5, D6, D7) LiquidCrystal lcd(8,9,10,11,12,13); #define led_pin 15 #define lcd_backlight 7 byte error, address; int nDevices; boolean led_status; char charbuf[6]; void setup() { Wire.begin(); Serial.begin(9600); Serial.println("\ni2c Scanner"); pinMode(led_pin, OUTPUT); pinMode(lcd_backlight, OUTPUT); digitalWrite( lcd_backlight, 1); // Akiduki i2c setup // ICON OFF,contrast(0-63),VDD=5V // LCD.Init(LCD_NOT_ICON,32,LCD_VDD5V) ; //change to 5V @20200612 // // LCD.SetCursor(0,0) ; // starting @1,1 line 1 & column 1 // LCD.Puts("i2c address scan") ; // buffer address [00H] // LCD.SetCursor(0,1) ; // starting @2,1 [40H] // LCD.Puts(" i2cLCDv1.0 ") ; // buffer address [40H] // PCF8574 i2c lcd // Iniatilize i2c LCD lcdi2c.init(); lcdi2c.backlight(); // 4 bits parallel LCD lcd.begin(16,2); // set lib for display size (2x16) lcd.clear(); // clear the screen } void loop() { Serial.println("i2c Scanning start"); digitalWrite(led_pin, led_status); led_status = !led_status; delay(1000); // LCD.SetCursor(0,0) ; // [00H] // LCD.Puts("i2c Scan test ") ; // lcdi2c.setCursor( 0, 0) ; // Set position lcdi2c.print( "i2c Scan test" ) ; // Let to display lcd.setCursor(0,0); lcd.print("i2c Scan test ") ; // LCD.SetCursor(0,1) ; // Set position @2,1 [40H] // LCD.Puts("ADR:") ; // LCD lcdi2c.setCursor( 0, 1) ; // Set column position lcdi2c.print( "ADR:" ) ; // Let to display lcd.setCursor(0,1); lcd.print("ADR:") ; nDevices = 0; for(address = 1; address < 127; address++ ) { // Check WIRE function return back result // The value of Write.endTransmisstion // Is there ACK response (yes:0) or no Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) // Got response { Serial.print("i2c device found at address 0x"); if (address<16) Serial.print("0"); Serial.print(address,HEX); Serial.println(" !"); sprintf(charbuf, "%02X", address ); // LCD.Puts("0x") ; // LCD.Puts(charbuf) ; // LCD.Puts(",") ; // lcdi2c.print("0x") ; lcdi2c.print(charbuf) ; lcdi2c.print(",") ; // lcd.print("0x") ; lcd.print(charbuf) ; lcd.print(",") ; 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 found\n"); // LCD.Puts("No devices found") ; lcdi2c.print("No devices found") ; lcd.print("No devices found") ; } else{ Serial.println("done\n"); // LCD.Puts("done "); lcdi2c.print("done ") ; lcd.print("done ") ; } delay(2000); // Wait 2 sec lcd.clear(); // clear the screen lcdi2c.clear(); // clear the screen }