Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of PE_08-01to04_ModularLCD by
Revision 1:66c78a2b81aa, committed 2014-12-07
- Comitter:
- Richard37
- Date:
- Sun Dec 07 22:55:13 2014 +0000
- Parent:
- 0:519ae7e3077e
- Commit message:
- Got our LCD Display working
Changed in this revision
diff -r 519ae7e3077e -r 66c78a2b81aa LCD.cpp --- a/LCD.cpp Fri May 24 21:33:46 2013 +0000 +++ b/LCD.cpp Sun Dec 07 22:55:13 2014 +0000 @@ -1,35 +1,66 @@ #include "LCD.h" -DigitalOut RS(p19); // RS -DigitalOut RW(p19); // RW -DigitalOut E(p20); // Enable -BusOut data(p21, p22, p23, p24);// DB4-DB7 +DigitalOut RS(A4); // RS +DigitalOut RW(A3); // RW +DigitalOut E(A5); // Enable +//BusOut data (D2, D3, D4, D5);// DB4-DB7 +BusOut data (D5, D4, D3, D2);// DB4-DB7 /****initialise LCD function ****/ void LCD_init(void){ - wait(0.02); RS=0; // set all low to write control/instruction data // RW=0; - E=0; + E=1; + + wait_ms(20); + data=0x3; // for our display see ted + toggle_enable(); + wait_ms(5); // must be more than 4.1ms + data=0x3; // for our display see ted + toggle_enable(); + wait_ms(1); // must be more than 100us + data=0x3; // for our display see ted + toggle_enable(); + wait_ms(5); // + data=0x2; // = 4 bit mode + toggle_enable(); // Function set + // N=0 : 2 lines (half lines!), F=0 : 5x7 font data=0x2; // = 4 bit mode toggle_enable(); data=0x8; // = 2-line mode, 7 dot characters toggle_enable(); // Display Mode + // Display: display off, cursor off, blink off data=0x0; // toggle_enable(); - data=0xF; // display on, cursor on, blink on + data=0x8; + toggle_enable(); +// Clear display + data=0x0; // + toggle_enable(); + data=0x1; + toggle_enable(); + // Set entry mode: ID=1, S=0 + data=0x0; // + toggle_enable(); + data=0x6; + toggle_enable(); + // Display: display on, cursor on, blink on + data=0x0; + toggle_enable(); + data=0xF; toggle_enable(); - // Clear display + + /*// Clear display data=0x0; // toggle_enable(); data=0x1; // clear - toggle_enable(); + toggle_enable();*/ } @@ -45,13 +76,25 @@ toggle_enable(); } +/**** display ****/ +void send_command_to_LCD(char value ){ + + RS=0; + //***** display character ***************** + data=value>>4; // value shifted right 4 = upper + toggle_enable(); + data=value&0x0F; // value bitmask with 0x0F = lower + toggle_enable(); +} + /**** toggle enable function ****/ void toggle_enable(void){ - E=1; wait(0.001); E=0; wait(0.001); + E=1; + wait(0.002); } /**** set location function ****/
diff -r 519ae7e3077e -r 66c78a2b81aa LCD.h --- a/LCD.h Fri May 24 21:33:46 2013 +0000 +++ b/LCD.h Sun Dec 07 22:55:13 2014 +0000 @@ -5,6 +5,7 @@ #include "mbed.h" void display_to_LCD(char value); //function to display characters on the LCD +void send_command_to_LCD(char value ); // function to send command to LCD void toggle_enable(void); //function to toggle the enable bit void LCD_init(void); //function to initialise the LCD
diff -r 519ae7e3077e -r 66c78a2b81aa main.cpp --- a/main.cpp Fri May 24 21:33:46 2013 +0000 +++ b/main.cpp Sun Dec 07 22:55:13 2014 +0000 @@ -5,14 +5,21 @@ #include "LCD.h" int main() { + int n; + const char line2[] = "Richard"; + LCD_init(); + display_to_LCD(0x48); // H display_to_LCD(0x45); // E display_to_LCD(0x4C); // L display_to_LCD(0x4C); // L display_to_LCD(0x4F); // O - for(char x=0x30;x<=0x39;x++){ + send_command_to_LCD(0xC0 ); + for (n=0 ; n<8 ; ++n) display_to_LCD(line2[n]); + /*for(char x=0x30;x<=0x39;x++){ display_to_LCD(x); // display numbers 0-9 - } + + }*/ }
diff -r 519ae7e3077e -r 66c78a2b81aa mbed.bld --- a/mbed.bld Fri May 24 21:33:46 2013 +0000 +++ b/mbed.bld Sun Dec 07 22:55:13 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file