PROPUESTA MAL REALIZADA
/*** Included libraries ***/
/*** Global variables and function definition ***/
const int LED_r = 3;
const int LED_g = 6;
const int LED_b = 11;
const int potentiometer = A0;
const int button = 13;
float LUZ = 0;
/*** Setup ***/
void setup() {
pinMode(LED_r, OUTPUT);
pinMode(LED_g, OUTPUT);
pinMode(LED_b, OUTPUT);
pinMode(potentiometer, INPUT);
pinMode(button, INPUT);
void ROJO() {
analogWrite(3, LUZ);
analogWrite(6, 0);
analogWrite(11, 0);
}
void VERDE() {
analogWrite(6, LUZ);
analogWrite(11, 0);
analogWrite(3, 0);
}
void AZUL() {
analogWrite(11, LUZ);
analogWrite(6, 0);
analogWrite(3, 0);
}
void CIAN() {
analogWrite(11, LUZ);
analogWrite(6, LUZ);
analogWrite(3, 0);
}
void AMARILLO() {
analogWrite(3, LUZ);
analogWrite(6, LUZ);
analogWrite(11, 0);
}
void MAGENTA() {
analogWrite(3, LUZ);
analogWrite(11, LUZ);
analogWrite(6, 0);
}
void APAGADO() {
analogWrite(3, 0);
analogWrite(11, 0);
analogWrite(6, 0);
}
}
/*** Loop ***/
void loop() {
LUZ = analogRead(potentiometer) / 4;
delay(200);
if (analogRead(potentiometer) == 1) {
if (LUZ == 0) {
APAGADO();
} else if (LUZ == 1) {
ROJO();
} else if (LUZ == 2) {
VERDE();
} else if (LUZ == 3) {
AZUL();
} else if (LUZ == 4) {
CIAN();
} else if (LUZ == 5) {
AMARILLO();
} else if (LUZ == 6) {
MAGENTA();
}
}
}
No hay comentarios:
Publicar un comentario