Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char str;
- const int buttonPin1 = 10;
- const int buttonPin2 = 11;
- const int buttonPin3= 12;
- const int buttonPin4= 13;
- int buttonState1 = 0;
- int buttonState2 = 0;
- int buttonState3 = 0;
- int buttonState4 = 0;
- void setup() {
- Serial.begin(9600);
- pinMode(buttonPin1,INPUT);
- pinMode(buttonPin2,INPUT);
- pinMode(buttonPin3,INPUT);
- pinMode(buttonPin4,INPUT);
- pinMode(2,OUTPUT);
- pinMode(3,OUTPUT);
- pinMode(4,OUTPUT);
- pinMode(5,OUTPUT);
- pinMode(6,OUTPUT);
- pinMode(7,OUTPUT);
- pinMode(8,OUTPUT);
- pinMode(9,OUTPUT);
- }
- void loop() {
- if(Serial.available()>0)
- {
- str = Serial.read();
- if(str =='A') digitalWrite(2,HIGH);
- delay(500);
- digitalWrite(2,LOW);
- if(str =='B') digitalWrite(3,HIGH);
- delay(500);
- digitalWrite(3,LOW);
- if(str =='C') digitalWrite(4,HIGH);
- delay(500);
- digitalWrite(4,LOW);
- if(str =='D') digitalWrite(5,HIGH);
- delay(500);
- digitalWrite(5,LOW);
- if(str =='E') digitalWrite(6,HIGH);
- delay(500);
- digitalWrite(6,LOW);
- if(str =='F') digitalWrite(7,HIGH);
- delay(500);
- digitalWrite(7,LOW);
- if(str =='G') digitalWrite(8,HIGH);
- delay(500);
- digitalWrite(8,LOW);
- if(str =='H') digitalWrite(9,HIGH);
- delay(500);
- digitalWrite(9,LOW);
- delay(500);
- buttonState1 = digitalRead(buttonPin1);
- buttonState2 = digitalRead(buttonPin2);
- buttonState3 = digitalRead(buttonPin3);
- buttonState4 = digitalRead(buttonPin4);
- if (buttonState1 == 1);
- Serial.write(1);
- if (buttonState2 == 1);
- Serial.write(2);
- }
- // put your main code here, to run repeatedly:
- }
Add Comment
Please, Sign In to add comment