Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int relay = 7;
- char data;
- // replay - task -2
- void setup() {
- pinMode(relay, OUTPUT);
- Serial.begin(9600);
- }
- void loop() {
- if(Serial.available()>0){
- // data available
- data = Serial.read();
- if(data=='a'){
- digitalWrite(relay, HIGH);
- Serial.println("Relay ON");
- }
- else if(data=='b'){
- digitalWrite(relay, LOW);
- Serial.println("Relay OFF");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement