Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial mySerial(2, 3); // RX, TX
- int val;
- int LED1 = 9;
- int LED2 = 10;
- int LED3 = 11;
- int LED4 = 12;
- void setup()
- {
- mySerial.begin(38400);
- pinMode(LED1, OUTPUT);
- pinMode(LED2, OUTPUT);
- pinMode(LED3, OUTPUT);
- pinMode(LED4, OUTPUT);
- digitalWrite(LED1, LOW);
- digitalWrite(LED2, LOW);
- digitalWrite(LED3, LOW);
- digitalWrite(LED4, LOW);
- }
- void loop()
- {
- if (mySerial.available())
- {
- val = mySerial.read();
- if (val == '1'){digitalWrite(LED1, HIGH);}
- if (val == '2'){digitalWrite(LED1, LOW);}
- if (val == '3'){digitalWrite(LED2, HIGH);}
- if (val == '4'){digitalWrite(LED2, LOW);}
- if (val == '5'){digitalWrite(LED3, HIGH);}
- if (val == '6'){digitalWrite(LED3, LOW);}
- if (val == '7'){digitalWrite(LED4, HIGH);}
- if (val == '8'){digitalWrite(LED4, LOW);}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement