Plymouth ELEC351 Group T / Mbed 2 deprecated 2017_12_271329_LCDTrial

Dependencies:   mbed

Committer:
chills
Date:
Wed Dec 27 15:10:44 2017 +0000
Revision:
0:87888ca85258
Child:
1:23bf1845cc2f
2017_12_27 15:07; LCD Turns On and Writes Character;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chills 0:87888ca85258 1 #include "mbed.h"
chills 0:87888ca85258 2
chills 0:87888ca85258 3 DigitalOut myled(LED1);
chills 0:87888ca85258 4
chills 0:87888ca85258 5 DigitalOut RS(D9);
chills 0:87888ca85258 6 DigitalOut RW(D4);
chills 0:87888ca85258 7 DigitalOut E(D8);
chills 0:87888ca85258 8 BusInOut DB(A0, A1, A2, A3, D7, D6, D3, D1); //LSB First
chills 0:87888ca85258 9
chills 0:87888ca85258 10 void clock_in();
chills 0:87888ca85258 11 void first_init_command();
chills 0:87888ca85258 12 void Function_Set();
chills 0:87888ca85258 13 void Display_Off();
chills 0:87888ca85258 14 void Display_Clear();
chills 0:87888ca85258 15 void Entry_Mode_Set();
chills 0:87888ca85258 16 void Display_On();
chills 0:87888ca85258 17 void DDRAM_Address(int Address);
chills 0:87888ca85258 18 void Write_Data(int Letter);
chills 0:87888ca85258 19
chills 0:87888ca85258 20 int main() {
chills 0:87888ca85258 21
chills 0:87888ca85258 22 DB.output();
chills 0:87888ca85258 23 first_init_command();
chills 0:87888ca85258 24 wait(0.005);
chills 0:87888ca85258 25 first_init_command();
chills 0:87888ca85258 26 wait(0.005);
chills 0:87888ca85258 27 first_init_command();
chills 0:87888ca85258 28 wait(0.020);
chills 0:87888ca85258 29 Function_Set();
chills 0:87888ca85258 30 wait(0.020);
chills 0:87888ca85258 31 Display_Off();
chills 0:87888ca85258 32 wait(0.020);
chills 0:87888ca85258 33 Display_Clear();
chills 0:87888ca85258 34 wait(0.020);
chills 0:87888ca85258 35 Entry_Mode_Set();
chills 0:87888ca85258 36 wait(0.020);
chills 0:87888ca85258 37 Display_On();
chills 0:87888ca85258 38 wait(0.020);
chills 0:87888ca85258 39 DDRAM_Address(0);
chills 0:87888ca85258 40 wait(0.020);
chills 0:87888ca85258 41 Write_Data(0x41);
chills 0:87888ca85258 42
chills 0:87888ca85258 43 }
chills 0:87888ca85258 44
chills 0:87888ca85258 45 void clock_in(){
chills 0:87888ca85258 46 E = 1; wait(0.01); E = 0; wait(0.01); E = 1;
chills 0:87888ca85258 47 }
chills 0:87888ca85258 48
chills 0:87888ca85258 49 void first_init_command(){
chills 0:87888ca85258 50 RS = 0; RW = 0; DB = 0x30; clock_in();
chills 0:87888ca85258 51 }
chills 0:87888ca85258 52
chills 0:87888ca85258 53 void Function_Set(){
chills 0:87888ca85258 54 RS = 0; RW = 0; DB = 0x3C; clock_in();
chills 0:87888ca85258 55 }
chills 0:87888ca85258 56
chills 0:87888ca85258 57 void Display_Off(){
chills 0:87888ca85258 58 RS = 0; RW = 0; DB = 0x08; clock_in();
chills 0:87888ca85258 59 }
chills 0:87888ca85258 60
chills 0:87888ca85258 61 void Display_Clear(){
chills 0:87888ca85258 62 RS = 0; RW = 0; DB = 0x01; clock_in();
chills 0:87888ca85258 63 }
chills 0:87888ca85258 64
chills 0:87888ca85258 65 void Entry_Mode_Set(){
chills 0:87888ca85258 66 RS = 0; RW = 0; DB = 0x06; clock_in();
chills 0:87888ca85258 67 }
chills 0:87888ca85258 68
chills 0:87888ca85258 69 void Display_On(){
chills 0:87888ca85258 70 RS = 0; RW = 0; DB = 0x0E; clock_in();
chills 0:87888ca85258 71 }
chills 0:87888ca85258 72
chills 0:87888ca85258 73 void DDRAM_Address(int Address){
chills 0:87888ca85258 74 RS = 0; RW = 0; DB = 0x80 + Address; clock_in();
chills 0:87888ca85258 75 }
chills 0:87888ca85258 76
chills 0:87888ca85258 77 void Write_Data(int Letter){
chills 0:87888ca85258 78 RS = 1; RW = 0; DB = Letter; clock_in();
chills 0:87888ca85258 79 }