Plymouth ELEC351 Group T / Mbed 2 deprecated 2017_12_271329_LCDTrial

Dependencies:   mbed

main.cpp

Committer:
chills
Date:
2017-12-27
Revision:
1:23bf1845cc2f
Parent:
0:87888ca85258
Child:
2:ed06e716cca2

File content as of revision 1:23bf1845cc2f:

#include "mbed.h"
#include <string>

DigitalOut myled(LED1);

DigitalOut RS(D9);
DigitalOut RW(D4);
DigitalOut E(D8);
BusInOut DB(A0, A1, A2, A3, D7, D6, D3, D1);        //LSB First

void clock_in();
void Function_Set();
void Display_Off();
void Display_Clear();
void Entry_Mode_Set();
void Display_On();
void DDRAM_Address(int Address);
void Write_Data(string Letter);
void Write_String(string Word);

int main() {
    
    DB.output();
    Function_Set();
    wait(0.020);
    Display_Off();
    wait(0.020);
    Display_Clear();
    wait(0.020);
    Entry_Mode_Set();
    wait(0.020);
    Display_On();
    wait(0.020);
    DDRAM_Address(0);
    wait(0.020);
    Write_String("Greetings");
    
}

void clock_in(){
    E = 1; wait(0.01); E = 0; wait(0.01); E = 1;
}

void Function_Set(){
    RS = 0; RW = 0; DB = 0x3C; clock_in();   
}

void Display_Off(){
    RS = 0; RW = 0; DB = 0x08; clock_in();    
}

void Display_Clear(){
    RS = 0; RW = 0; DB = 0x01; clock_in();   
}

void Entry_Mode_Set(){
    RS = 0; RW = 0; DB = 0x06; clock_in();   
}

void Display_On(){
    RS = 0; RW = 0; DB = 0x0E; clock_in();   
}

void DDRAM_Address(int Address){
    RS = 0; RW = 0; DB = 0x80 + Address; clock_in();    
}

void Write_Data(string Letter){
    
    int ASCII_Converted[32];
     
    for (int i = 0; i < Letter.length(); i++)
    {
        ASCII_Converted[i] = Letter.at(i);
        
    }    
     
     RS = 1; RW = 0; DB = ASCII_Converted[0]; clock_in();

}

void Write_String(string Word){
    
    int ASCII_Converted;
    for (int i = 0; i < Word.length(); i++)
    {
        ASCII_Converted = Word.at(i);
        DDRAM_Address(i); //wait(0.020);
        RS = 1; RW = 0; DB = ASCII_Converted; clock_in();
    }    
    
     

}