Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C++ code
- //
- void send_8bits_command(int RS1,int D01,int D11,int D21,int D31,int D41,int D51,int D61,int D71);
- void send_4bits_command(int RS1,int D01,int D11,int D21,int D31,int D41,int D51,int D61,int D71);
- #define D0 9
- #define D1 8
- #define D2 7
- #define D3 6
- #define D4 5
- #define D5 4
- #define D6 3
- #define D7 2
- #define RS 13
- #define E 12
- //#define 4bit_mode send_8bits_command(0,0,0,0,0,0,1,0,0)
- //#define clear_display send_4bits_command(0,0,0,0,0,0,0,0,1);
- //#define return_home send_4bits_command(0,0,0,0,0,0,0,1,0);
- //#define display_on send_4bits_command(0,0,0,1,0,1,0,0,0);
- void setup()
- {
- pinMode(D0 , OUTPUT);
- pinMode(D1 , OUTPUT);
- pinMode(D2 , OUTPUT);
- pinMode(D3 , OUTPUT);
- pinMode(D4 , OUTPUT);
- pinMode(D5 , OUTPUT);
- pinMode(D6 , OUTPUT);
- pinMode(D7 , OUTPUT);
- pinMode(RS , OUTPUT);
- pinMode(E , OUTPUT);
- send_8bits_command(0,0,0,0,0,0,1,0,0);
- send_4bits_command(0,0,0,0,0,0,0,0,1);
- send_4bits_command(0,0,0,0,0,0,0,1,0);
- send_4bits_command(0,0,0,0,0,1,1,0,0);
- }
- void loop()
- {
- send_4bits_command(1,0,1,0,0,0,0,0,1);
- //send_4bits_command(0,1,0,0,0,1,1,0,0);
- delay(1000);
- send_4bits_command(1,0,1,0,0,0,0,1,0);
- //send_4bits_command(0,1,0,0,0,1,1,0,0);
- delay(1000);
- send_4bits_command(1,0,1,0,0,0,0,1,1);
- //send_4bits_command(0,1,0,0,0,1,1,0,0);
- delay(1000);
- //send_4bits_command(0,0,0,0,0,0,0,0,1);
- //send_4bits_command(0,0,0,0,0,0,0,1,0);
- send_4bits_command(0,1,0,0,0,0,0,0,0);
- }
- void send_8bits_command(int RS1,int D01,int D11,int D21,int D31,int D41,int D51,int D61,int D71)
- {
- digitalWrite(RS,RS1);
- digitalWrite(D0,D01);
- digitalWrite(D1,D11);
- digitalWrite(D2,D21);
- digitalWrite(D3,D31);
- digitalWrite(D4,D41);
- digitalWrite(D5,D51);
- digitalWrite(D6,D61);
- digitalWrite(D7,D71);
- digitalWrite(E,LOW);
- digitalWrite(E,HIGH);
- digitalWrite(E,LOW);
- delay(1);
- }
- void send_4bits_command(int RS1,int D01,int D11,int D21,int D31,int D41,int D51,int D61,int D71){
- digitalWrite(RS,RS1);
- digitalWrite(D7,D01);
- digitalWrite(D6,D11);
- digitalWrite(D5,D21);
- digitalWrite(D4,D31);
- digitalWrite(E,LOW);
- digitalWrite(E,HIGH);
- digitalWrite(E,LOW);
- delay(1);
- digitalWrite(RS,RS1);
- digitalWrite(D7,D41);
- digitalWrite(D6,D51);
- digitalWrite(D5,D61);
- digitalWrite(D4,D71);
- digitalWrite(E,LOW);
- digitalWrite(E,HIGH);
- digitalWrite(E,LOW);
- delay(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement