share
Dependencies: mbed
lcd.cpp
- Committer:
- shaizeen
- Date:
- 2015-11-13
- Revision:
- 0:5dbeda619328
File content as of revision 0:5dbeda619328:
// LCD.cpp File #include "lcd.h"// Define mbed objects DigitalOut RS(p26) ; DigitalOut E(p25) ; BusOut data(p24, p23, p22, p21) ; // Toggle enable function void toggle_enable(void) { E = 1 ; wait(0.001) ; E = 0 ; wait(0.001) ; }// Initialise LCD function void LCD_init(void) { wait(0.02) ; RS = 0 ; E = 0 ; // Function mode data = 0x2 ; toggle_enable( ) ; data = 0x8 ; toggle_enable( ) ; // Display mode data = 0x0 ; toggle_enable( ) ; data = 0xF ; toggle_enable( ) ; // Clear display data = 0x0 ; toggle_enable( ) ; data = 0x1 ; toggle_enable( ) ; } // Display function void display_to_LCD(char value ) { RS = 1;// display character data = value >> 4 ; // Upper 4 toggle_enable( ) ; data = value & 0x0F ; // Lower 4 toggle_enable( ) ; }