Sabes gatul, lo hice como Tú lo hiciste, pero mientras tanto me surgió necesario, que necesito "algo", que funcione desde la mitad del programa, y aumenté un botón más.
Hice la prueba y todo funciona muy bien ![]()
Ahí viene el programa:
const int buttonPin1 = 2;
const int ledPin = 13;
const int buttonPin2 = 4;
const int buttonPin3 = 7;
int i = 0;
int delayTime = 3000;
void setup()
{
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
}
void loop()
{
int pin1State = digitalRead(buttonPin1);
int pin2State = digitalRead(buttonPin2);
int pin3State = digitalRead(buttonPin3);
if (i == 0) {
if (pin1State == LOW)
{
i = 1;
}
}
if (i == 1) {
if (pin2State == LOW)
{
i = 2;
}
}
if (i == 2)
{
digitalWrite(ledPin, HIGH);
i = 3;
}
if (i == 3) {
if (pin2State == LOW)
{
i = 4;
}
}
if (i == 4) {
if (pin1State == LOW)
{
i = 5;
}
}
if (i == 5)
{
delay(delayTime);
digitalWrite(ledPin, LOW);
i = 0;
}
if (i == 0) {
if (pin3State == LOW)
{
i = 6;
}
}
if (i == 6) {
if (pin2State == LOW)
{
i = 7;
}
}
if (i == 7)
{
digitalWrite(ledPin, HIGH);
i = 8;
}
if (i == 8) {
if (pin1State == LOW)
{
i = 9;
}
}
if (i == 9)
{
delay(delayTime);
digitalWrite(ledPin, LOW);
i = 0;
}
}
Quisiera agradecer también a todos que hicieron cualquier comentario.
¡Sois los mejores!
Saludos ![]()