Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:23bf1845cc2f
- Parent:
- 0:87888ca85258
- Child:
- 2:ed06e716cca2
--- a/main.cpp Wed Dec 27 15:10:44 2017 +0000 +++ b/main.cpp Wed Dec 27 15:27:32 2017 +0000 @@ -1,4 +1,5 @@ #include "mbed.h" +#include <string> DigitalOut myled(LED1); @@ -8,24 +9,18 @@ BusInOut DB(A0, A1, A2, A3, D7, D6, D3, D1); //LSB First void clock_in(); -void first_init_command(); void Function_Set(); void Display_Off(); void Display_Clear(); void Entry_Mode_Set(); void Display_On(); void DDRAM_Address(int Address); -void Write_Data(int Letter); +void Write_Data(string Letter); +void Write_String(string Word); int main() { DB.output(); - first_init_command(); - wait(0.005); - first_init_command(); - wait(0.005); - first_init_command(); - wait(0.020); Function_Set(); wait(0.020); Display_Off(); @@ -38,17 +33,13 @@ wait(0.020); DDRAM_Address(0); wait(0.020); - Write_Data(0x41); + Write_String("Greetings"); } void clock_in(){ E = 1; wait(0.01); E = 0; wait(0.01); E = 1; } - -void first_init_command(){ - RS = 0; RW = 0; DB = 0x30; clock_in(); -} void Function_Set(){ RS = 0; RW = 0; DB = 0x3C; clock_in(); @@ -74,6 +65,30 @@ RS = 0; RW = 0; DB = 0x80 + Address; clock_in(); } -void Write_Data(int Letter){ - RS = 1; RW = 0; DB = Letter; 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(); + } + + + +}