Paso 16: programa de
/* Tweeting Christmas Tree receiver code Controls the color of Christmas tree lights 'a' turns red on 'b' turns red off 'c' turns green on 'd' turns green off 'e' turns white on 'f' turns white off 'g' turns other on 'h' turns yother off */ int sentDat; void setup() { Serial.begin(9600); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); } void loop() { if (Serial.available() > 0) { sentDat = Serial.read(); //red control if(sentDat == 'a'){ digitalWrite(3, HIGH); }else if(sentDat == 'b'){ digitalWrite(3, LOW); } //green control if(sentDat == 'c'){ digitalWrite(4, HIGH); }else if(sentDat == 'd'){ digitalWrite(4, LOW); } //blue control if(sentDat == 'e'){ digitalWrite(5, HIGH); }else if(sentDat == 'f'){ digitalWrite(5, LOW); } //other control if(sentDat == 'g'){ digitalWrite(6, HIGH); }else if(sentDat == 'h'){ digitalWrite(6, LOW); } } }
Cuando termine programar, desconecte el cable USB y mueva el interruptor a "micro".