VERSIÓN 2


/***   Included libraries  ***/


/***   Global variables and function definition  ***/
const int azul = 10;
const int rojo = 6;
const int verde = 3;
const int button = 13;
const int potentiometer = A0;

float Luz = 0;
float ESTADO = 0;
void CAMBIO_ESTADO() {
    if (ESTADO == 3) {
        ESTADO = 0;
    } else {
        ESTADO = ESTADO + 1;
    }
}



/***   Setup  ***/
void setup() {
    pinMode(azul, OUTPUT);
    pinMode(rojo, OUTPUT);
    pinMode(verde, OUTPUT);
    pinMode(button, INPUT);
    pinMode(potentiometer, INPUT);

}


/***   Loop  ***/
void loop() {
    if (digitalRead(button) == 1) {
        CAMBIO_ESTADO();
        delay(2000);
    } else if (ESTADO == 1) {
        analogWrite(3, analogRead(potentiometer));
    } else if (ESTADO == 2) {
        analogWrite(6, analogRead(potentiometer));
    } else if (ESTADO == 3) {
        analogWrite(9, analogRead(potentiometer));
    }
}

Comentarios

Entradas populares de este blog

Redes informáticas :)

Sensor de luz: VERSIÓN 1.0

CÓDIGO 2 (recuperar línea)