Paso 3: Paso 3: codificación de Arduino
Copie y pegue el código siguiente para su lámpara:
void setup() {}
pinMode(redLed,OUTPUT); pinMode(greenLed,OUTPUT); pinMode(blueLed,OUTPUT); digitalWrite(redLed,HIGH); digitalWrite(greenLed,LOW); digitalWrite(blueLed,LOW); }
void loop() {para (int y = 0; y < = 3; y ++) {si (y = 1) {para (int x = 0; x < = 255; x ++) {RGB [0] = 255-x; RGB [1] = 0; RGB [2] = 0 + x; analogWrite(redLed,RGB[0]); analogWrite(greenLed,RGB[1]); analogWrite(blueLed,RGB[2]); Delay(delaymood); }} Si (y = 2) {para (int x = 0; x < = 255; x ++) {RGB [0] = 0; RGB [1] = 0 + x; RGB [2] = 255-x; analogWrite(redLed,RGB[0]); analogWrite(greenLed,RGB[1]); analogWrite(blueLed,RGB[2]); Delay(delaymood); }} Si (y = 3) {para (int x = 0; x < = 255; x ++) {RGB [0] = 0 + x; RGB [1] = 255-x; RGB [2] = 0; analogWrite(redLed,RGB[0]); analogWrite(greenLed,RGB[1]); analogWrite(blueLed,RGB[2]); Delay(delaymood); } } } }