Gewerblich-Technische Schule Offenburg
/
Nucleo_I2C-LCD
I2C LCD
Fork of I2C-LCD by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 00002 /* 00003 Programm für eine IIC LC-Display mit verschiedenen Formaten wie 16x2 16x4 20x4 00004 Dieses Programm funktioniert mit einen 00005 Adapter mit aufgelötetem Poti 00006 nicht mit Poti zum auf die Seite klappen 00007 G.Neumaier Feb 2018 getestet 00008 */ 00009 00010 #include "mbed.h" 00011 #include "TextLCD.h" 00012 00013 float mess0; 00014 // I2C Communication 00015 I2C i2c_lcd(PB_9,PB_8); // SDA, SCL Nucleo F103RB Board 00016 TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD20x4, TextLCD::HD44780); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type 00017 //LCD Type possible for example: LCD16x2, LCD20x4 00018 //!!Adress here is 0x4E normal adress 0x27, but thats the same, you have to shift left 00019 // Adress-shift: 0100 1110 <- 0010 0111 (0x27) 00020 00021 AnalogIn ana_A0(A0); //same as Pin PA_0 00022 00023 int main() 00024 { 00025 lcd.setMode(TextLCD::DispOn); //DispOff, DispOn 00026 lcd.setBacklight(TextLCD::LightOff);//LightOff, LightOn ->!LightOff->on! 00027 lcd.setCursor(TextLCD::CurOff_BlkOff);//CurOff_BlkOff, CurOn_BlkOff, CurOff_BlkOn, CurOn_BlkOn 00028 00029 //example for a display with 16x4 signs, a 16x2 display show you only two rows(Zeile) 00030 while(1) { 00031 lcd.printf("Gerhard Neumaier\n" ); // \n will produce newcolumn 00032 lcd.printf(" Offenburg \n" ); // \n will produce newcolumn 00033 // lcd.printf("Number: %d-\n", 1265); // dezimal number 00034 lcd.setAddress(2, 3);//column(Spalte), row (Zeile) beginning by0 00035 mess0 = ana_A0.read(); // Converts and read the analog input value (value from 0.0 to 1.0) 00036 mess0 = mess0*3.3; 00037 lcd.printf("Volt:%.3f\n", mess0); //float number with 3signs behind comma 00038 //lcd.putc('-'); //one sign 00039 wait_ms(300); 00040 } 00041 }
Generated on Thu Jul 14 2022 05:46:56 by 1.7.2