share
Dependencies: mbed
Diff: lcd.cpp
- Revision:
- 0:5dbeda619328
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lcd.cpp Fri Nov 13 02:03:19 2015 +0000 @@ -0,0 +1,49 @@ +// 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( ) ; + + } \ No newline at end of file