// PINES
#define SW1 3
#define SW0 2
#define POWER 5
/*
const int LED0 13;
const int LED1 12;
const int LED2 11;
const int LED3 10;
*/
const int LED_ARRAY[] = {13, 12, 11, 10};
int sw1, sw0, power;
void setup() {
Serial.begin(9600);
// switches
pinMode(SW1, INPUT);
pinMode(SW0, INPUT);
pinMode(POWER, INPUT);
// Leds
/*
pinMode(LED_ARRAY[0], OUTPUT);
pinMode(LED_ARRAY[1], OUTPUT);
pinMode(LED_ARRAY[2], OUTPUT);
pinMode(LED_ARRAY[3], OUTPUT);
*/
for(int i = 0; i < 4;i++) {
pinMode(LED_ARRAY[i], OUTPUT);
}
Serial.println("Dispositivo configurado: OK");
}
void loop() {
// put your main code here, to run repeatedly:
sw1 = digitalRead(SW1);
sw0 = digitalRead(SW0);
power = digitalRead(POWER);
/*
Serial.print("Sw1: ");
Serial.print(sw1);
Serial.print(" ---- Sw0: ");
Serial.println(sw0);
*/
if(power == HIGH) {
if((sw1 == LOW) && (sw0 == LOW)) {
digitalWrite(LED_ARRAY[0], HIGH);
digitalWrite(LED_ARRAY[1], LOW);
digitalWrite(LED_ARRAY[2], LOW);
digitalWrite(LED_ARRAY[3], LOW);
}
else if((sw1 == LOW) && (sw0 == HIGH)) {
digitalWrite(LED_ARRAY[0], LOW);
digitalWrite(LED_ARRAY[1], HIGH);
digitalWrite(LED_ARRAY[2], LOW);
digitalWrite(LED_ARRAY[3], LOW);
}
else if((sw1 == HIGH) && (sw0 == LOW)) {
digitalWrite(LED_ARRAY[0], LOW);
digitalWrite(LED_ARRAY[1], LOW);
digitalWrite(LED_ARRAY[2], HIGH);
digitalWrite(LED_ARRAY[3], LOW);
}
else {
digitalWrite(LED_ARRAY[0], LOW);
digitalWrite(LED_ARRAY[1], LOW);
digitalWrite(LED_ARRAY[2], LOW);
digitalWrite(LED_ARRAY[3], HIGH);
}
}
else {
digitalWrite(LED_ARRAY[0], LOW);
digitalWrite(LED_ARRAY[1], LOW);
digitalWrite(LED_ARRAY[2], LOW);
digitalWrite(LED_ARRAY[3], LOW);
}
delay(100);
}