I2C LCD

Dependencies:   TextLCD mbed

Fork of I2C-LCD by Oscar de Jesus Vasquez

IIC-LCDisplay

here you can see my hardware: /media/uploads/schlaumaier54/dscn2996.jpg Detail with the IIC-Hardware: /media/uploads/schlaumaier54/dscn2994.jpg

And here a PDF dokument:

/media/uploads/schlaumaier54/iic_lcdisplays_mit_quellcode.pdf

Neumaier Feb. 2018

Committer:
schlaumaier54
Date:
Thu Feb 08 15:14:11 2018 +0000
Revision:
1:b51c02181e1c
Parent:
0:376d7a150177
LCD Displays with I2C (IIC)-bus and IC PCF8574. It is possible for running different formats: 16x2; 16x4 20x2; 40x2   LCD-Controller HD44...

Who changed what in which revision?

UserRevisionLine numberNew contents of line
schlaumaier54 1:b51c02181e1c 1
schlaumaier54 1:b51c02181e1c 2 /*
schlaumaier54 1:b51c02181e1c 3 Programm für eine IIC LC-Display mit verschiedenen Formaten wie 16x2 16x4 20x4
schlaumaier54 1:b51c02181e1c 4 Dieses Programm funktioniert mit einen
schlaumaier54 1:b51c02181e1c 5 Adapter mit aufgelötetem Poti
schlaumaier54 1:b51c02181e1c 6 nicht mit Poti zum auf die Seite klappen
schlaumaier54 1:b51c02181e1c 7 G.Neumaier Feb 2018 getestet
schlaumaier54 1:b51c02181e1c 8 */
schlaumaier54 1:b51c02181e1c 9
oscarvzfz 0:376d7a150177 10 #include "mbed.h"
oscarvzfz 0:376d7a150177 11 #include "TextLCD.h"
oscarvzfz 0:376d7a150177 12
schlaumaier54 1:b51c02181e1c 13 float mess0;
oscarvzfz 0:376d7a150177 14 // I2C Communication
schlaumaier54 1:b51c02181e1c 15 I2C i2c_lcd(PB_9,PB_8); // SDA, SCL Nucleo F103RB Board
schlaumaier54 1:b51c02181e1c 16 TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD20x4, TextLCD::HD44780); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type
schlaumaier54 1:b51c02181e1c 17 //LCD Type possible for example: LCD16x2, LCD20x4
schlaumaier54 1:b51c02181e1c 18 //!!Adress here is 0x4E normal adress 0x27, but thats the same, you have to shift left
schlaumaier54 1:b51c02181e1c 19 // Adress-shift: 0100 1110 <- 0010 0111 (0x27)
schlaumaier54 1:b51c02181e1c 20
schlaumaier54 1:b51c02181e1c 21 AnalogIn ana_A0(A0); //same as Pin PA_0
oscarvzfz 0:376d7a150177 22
schlaumaier54 1:b51c02181e1c 23 int main()
oscarvzfz 0:376d7a150177 24 {
schlaumaier54 1:b51c02181e1c 25 lcd.setMode(TextLCD::DispOn); //DispOff, DispOn
schlaumaier54 1:b51c02181e1c 26 lcd.setBacklight(TextLCD::LightOff);//LightOff, LightOn ->!LightOff->on!
schlaumaier54 1:b51c02181e1c 27 lcd.setCursor(TextLCD::CurOff_BlkOff);//CurOff_BlkOff, CurOn_BlkOff, CurOff_BlkOn, CurOn_BlkOn
schlaumaier54 1:b51c02181e1c 28
schlaumaier54 1:b51c02181e1c 29 //example for a display with 16x4 signs, a 16x2 display show you only two rows(Zeile)
schlaumaier54 1:b51c02181e1c 30 while(1) {
schlaumaier54 1:b51c02181e1c 31 lcd.printf("Gerhard Neumaier\n" ); // \n will produce newcolumn
schlaumaier54 1:b51c02181e1c 32 lcd.printf(" Offenburg \n" ); // \n will produce newcolumn
schlaumaier54 1:b51c02181e1c 33 // lcd.printf("Number: %d-\n", 1265); // dezimal number
schlaumaier54 1:b51c02181e1c 34 lcd.setAddress(2, 3);//column(Spalte), row (Zeile) beginning by0
schlaumaier54 1:b51c02181e1c 35 mess0 = ana_A0.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
schlaumaier54 1:b51c02181e1c 36 mess0 = mess0*3.3;
schlaumaier54 1:b51c02181e1c 37 lcd.printf("Volt:%.3f\n", mess0); //float number with 3signs behind comma
schlaumaier54 1:b51c02181e1c 38 //lcd.putc('-'); //one sign
schlaumaier54 1:b51c02181e1c 39 wait_ms(300);
schlaumaier54 1:b51c02181e1c 40 }
schlaumaier54 1:b51c02181e1c 41 }