#define ledRosso 9
#define ledBlu 10
#define ledVerde 11
#define ledGiallo 12
#define button1 7
#define button2 6
int cont=0;
void setup()
{
pinMode (button1 ,INPUT);
pinMode (button2 ,INPUT);
pinMode (ledRosso,OUTPUT);
pinMode (ledGiallo,OUTPUT);
pinMode (ledVerde,OUTPUT);
pinMode (ledBlu,OUTPUT);
}
void loop()
{
if (digitalRead(button1)==HIGH)
{
delay(200);
cont==0;
}
if (digitalRead(button2)==HIGH)
{
delay(200);
cont==1;
}
switch(cont)
{
case 0:
digitalWrite (ledRosso,HIGH);
digitalWrite (ledBlu,HIGH);
digitalWrite (ledVerde,HIGH);
digitalWrite (ledGiallo,HIGH);
delay(2000);
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,LOW);
digitalWrite (ledVerde,LOW);
digitalWrite (ledGiallo,LOW);
delay(2000);
break;
case 1:
digitalWrite (ledRosso,HIGH);
digitalWrite (ledBlu,HIGH);
digitalWrite (ledVerde,HIGH);
digitalWrite (ledGiallo,HIGH);
delay(1000);
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,LOW);
digitalWrite (ledVerde,LOW);
digitalWrite (ledGiallo,LOW);
delay(1000);
break;
}
}
______________________________________________________________________________
#define ledRosso 9
#define ledBlu 10
#define ledVerde 11
#define ledGiallo 12
#define button 7
void setup()
{
pinMode (button1 ,INPUT);
pinMode (button2 ,INPUT);
pinMode (ledRosso,OUTPUT);
pinMode (ledGiallo,OUTPUT);
pinMode (ledVerde,OUTPUT);
pinMode (ledBlu,OUTPUT);
}
void loop()
{
if (digitalRead(button1)==HIGH)
{
digitalWrite (ledRosso,HIGH);
digitalWrite (ledBlu,HIGH);
digitalWrite (ledVerde,HIGH);
digitalWrite (ledGiallo,HIGH);
delay(2000);
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,LOW);
digitalWrite (ledVerde,LOW);
digitalWrite (ledGiallo,LOW);
delay(2000);
}
if (digitalRead(button2)==HIGH)
{
digitalWrite (ledRosso,HIGH);
digitalWrite (ledBlu,HIGH);
digitalWrite (ledVerde,HIGH);
digitalWrite (ledGiallo,HIGH);
delay(1000);
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,LOW);
digitalWrite (ledVerde,LOW);
digitalWrite (ledGiallo,LOW);
delay(1000);
}
}
_______________________________________________________________________________
#define ledRosso 9
#define ledBlu 10
#define ledVerde 11
#define ledGiallo 12
#define button 7
void setup()
{
int i=0;
pinMode (button ,INPUT);
pinMode (ledRosso,OUTPUT);
pinMode (ledGiallo,OUTPUT);
pinMode (ledVerde,OUTPUT);
pinMode (ledBlu,OUTPUT);
}
void loop()
{
if (digitalRead(button)==HIGH)
{
delay(200);
i++;
}
switch(i)
{
case 0:
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,LOW);
digitalWrite (ledVerde,LOW);
digitalWrite (ledGiallo,LOW);
break;
case 1:
digitalWrite (ledRosso,HIGH);
break;
case 2:
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,HIGH);
break;
case 3:
digitalWrite (ledRosso,HIGH);
digitalWrite (ledBlu,HIGH);
break;
case 4:
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,LOW);
digitalWrite (ledVerde,HIGH);
break;
case 5:
digitalWrite (ledRosso,HIGH);
break;
case 6:
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,HIGH);
break;
case 7:
digitalWrite (ledRosso,HIGH);
break;
case 8:
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,LOW);
digitalWrite (ledVerde,LOW);
digitalWrite (ledGiallo,HIGH);
break;
case 9:
digitalWrite (ledRosso,HIGH);
break;
case 10:
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,HIGH);
break;
case 11:
digitalWrite (ledRosso,HIGH);
break;
case 12:
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,LOW);
digitalWrite (ledVerde,HIGH);
break;
case 13:
digitalWrite (ledRosso,HIGH);
break;
case 14:
digitalWrite (ledRosso,LOW);
digitalWrite (ledBlu,HIGH);
break;
case 15:
digitalWrite (ledRosso,HIGH);
break;
case 16:
i=0;
break;
}
}
Nessun commento:
Posta un commento