Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C++ code
- //
- const int RS = 13;
- const int E = 12;
- const int DB4 = 11;
- const int DB5 = 10;
- const int DB6 = 9;
- const int DB7 = 8;
- void setup()
- {
- pinMode(RS, OUTPUT);
- pinMode(E, OUTPUT);
- pinMode(DB4, OUTPUT);
- pinMode(DB5, OUTPUT);
- pinMode(DB6, OUTPUT);
- pinMode(DB7, OUTPUT);
- //initialize
- initlcd();
- sent(1,0,0,1,0); sent(1,0,0,0,1); //H
- sent(1,0,0,1,0); sent(1,1,0,0,1); //I
- writeAlpha(' ');
- writeAlpha('A');
- writeAlpha('B');
- writeAlpha('C');
- }
- void loop()
- {
- }
- void initlcd()
- {
- sent(0,0,1,0,0);
- sent(0,0,0,0,0); sent(0,1,0,0,0);
- sent(0,0,0,0,0); sent(0,0,1,0,0);
- sent(0,0,0,0,0); sent(0,0,0,1,1);
- }
- void writeAlpha(char ch)
- {
- switch(ch){
- //0010 0000
- case ' ': sent(1,0,1,0,0); sent(1,0,0,0,0); break;
- //
- case 'A': sent(1,0,0,1,0); sent(1,1,0,0,0); break;
- //0100 0010
- case 'B': sent(1,0,0,1,0); sent(1,0,1,0,0); break;
- //0100 0011
- case 'C': sent(1,0,0,1,0); sent(1,1,1,0,0); break;
- }
- }
- void sent(int rs,int db4,int db5,int db6,int db7)
- {
- digitalWrite(RS,rs);
- delay(10);
- digitalWrite(DB4,db4);
- digitalWrite(DB5,db5);
- digitalWrite(DB6,db6);
- digitalWrite(DB7,db7);
- delay(10);
- digitalWrite(E,0);
- delay(10);
- digitalWrite(E,1);
- delay(10);
- digitalWrite(E,0);
- delay(10);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement