const int correcto1 = 2;
const int correcto2 = 3;
const int correcto3 = 4;
const int fallo1 = 5;
const int ledOk = 11;
const int ledError = 10;
bool is_correct1_cutted = false;
bool is_correct2_cutted = false;
bool is_correct3_cutted = false;
void setup() {
pinMode(fallo1, INPUT);
pinMode(correcto1, INPUT);
pinMode(correcto2, INPUT);
pinMode(correcto3, INPUT);
pinMode(ledError, OUTPUT);
pinMode(ledOk, OUTPUT);
}
void loop() {
int estado_fallo1 = digitalRead(fallo1);
int estado_correcto1 = digitalRead(correcto1);
int estado_correcto2 = digitalRead(correcto2);
int estado_correcto3 = digitalRead(correcto3);
if (estado_fallo1 == LOW) {
digitalWrite(ledError, HIGH);
digitalWrite(ledOk, LOW);
while(1);
} else {
digitalWrite(ledError, LOW);
}
if (estado_correcto1 == LOW && (estado_correcto2 == HIGH && estado_correcto3 == HIGH))
{
is_correct1_cutted = true;
}
if (is_correct1_cutted && (estado_correcto2 == LOW && estado_correcto3 == HIGH))
{
is_correct2_cutted = true;
}
if (is_correct1_cutted && (is_correct2_cutted && estado_correcto3 == LOW))
{
is_correct3_cutted = true;
}
if (is_correct3_cutted == true)
{
digitalWrite(ledOk, HIGH);
while (1);
}
if (estado_correcto1 == HIGH && (estado_correcto2 == LOW && estado_correcto3 == HIGH))
{
digitalWrite(ledError, HIGH);
}
if (estado_correcto1 == HIGH && (estado_correcto2 == HIGH && estado_correcto3 == LOW))
{
digitalWrite(ledError, HIGH);
}
}
i've posted this program earlier about "cutting wires". this is the link:
the code works like:
I have 4 wires, 1 of them "fallo1" turns on a red led when "cutted out" meaning game over.
the other 3 wires it's neccesary to "cut them" in certain order (first correcto1, correcto2 and then correcto3).
if you "cut them" in any other order, it should turn on a red led.
My problem is when i "cut" (correcto1) everithing is okay, but when I cut the secon one, (correcto2 or correcto3) it turns on the red led but at half of the power.
Thanks for reading
