LCD from base

Dependencies:   mbed

Dependents:   TP53

Files at this revision

API Documentation at this revision

Comitter:
HarishMekali
Date:
Mon Feb 18 07:09:47 2013 +0000
Commit message:
LCD by writing our lib

Changed in this revision

LCD.cpp Show annotated file Show diff for this revision Revisions of this file
LCD.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD.cpp	Mon Feb 18 07:09:47 2013 +0000
@@ -0,0 +1,41 @@
+// LCD.cpp file
+#include "LCD.h"
+//define mbed objects
+DigitalOut RS(p19);
+DigitalOut E(p20);
+BusOut data(p21, p22, p23, p24);
+//toggle enable function
+void toggle_enable(void) {
+E=1;
+wait(0.001);
+E=0;
+wait(0.001);
+}
+void LCD_init(void) { //initialize LCD function
+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;
+data=value>>4;
+toggle_enable();
+data=value&0x0F;
+toggle_enable();
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD.h	Mon Feb 18 07:09:47 2013 +0000
@@ -0,0 +1,8 @@
+// LCD.h file
+#ifndef LCD_H
+#define LCD_H
+#include "mbed.h"
+void display_to_LCD(char value); //function to display characters on the LCD
+void toggle_enable(void); //function to toggle the enable bit
+void LCD_init(void); //function to initialise the LCD
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 18 07:09:47 2013 +0000
@@ -0,0 +1,19 @@
+#include "mbed.h"
+#include "LCD.h"
+int main() {
+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’
+display_to_LCD(0x20); // ‘ ’
+display_to_LCD(0x46); // ‘F’
+display_to_LCD(0x41); // ‘A’
+display_to_LCD(0x43); // ‘C’
+display_to_LCD(0x55); // ‘U’
+display_to_LCD(0x4C); // ‘L’
+display_to_LCD(0x54); // ‘T’
+display_to_LCD(0x59); // ‘Y’
+display_to_LCD(0x21); // ‘!’
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 18 07:09:47 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59
\ No newline at end of file