/*
Discord | Arduino | coding-help
DanyX — 2/25/24 at 4:17 PM
*/
int led1 = 10;
int led2 = 9;
int led3 = 8;
int tempo_attuale = 0;
int tempo_precedente_1 = 0;
int tempo_precedente_2 = 0;
int tempo_precedente_3 = 0;
int tempo_ricorrente1 = 500;
int tempo_ricorrente2 = 1000;
int tempo_ricorrente3 = 2000;
int state3 = 0;
void setup()
{
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
Serial.begin(9600);
}
void loop()
{
tempo_attuale = millis();
if (tempo_attuale - tempo_precedente_1 >= tempo_ricorrente1)
{
tempo_precedente_1 = tempo_attuale;
if (digitalRead(led1) == 1)
{
digitalWrite(led1, 0);
}
else
{
digitalWrite(led1, 1);
}
}
if (tempo_attuale - tempo_precedente_2 >= tempo_ricorrente2)
{
tempo_precedente_2 = tempo_attuale;
if (digitalRead(led2) == 1)
{
digitalWrite(led2, 0);
}
else
{
digitalWrite(led2, 1);
}
}
if (tempo_attuale - tempo_precedente_3 >= tempo_ricorrente3) {
tempo_precedente_3 = tempo_attuale;
state3 = !state3;
digitalWrite(led3, state3);
}
Serial.println(tempo_attuale);
}