int redLed =2;
int yellowLed =3;
int greenLed =4;
void setup() {
pinMode(redLed,OUTPUT);
pinMode(yellowLed,OUTPUT);
pinMode(greenLed,OUTPUT);
}
void loop() {
digitalWrite(redLed,HIGH);
digitalWrite(yellowLed,HIGH);
digitalWrite(greenLed,HIGH);
delay(200);
digitalWrite(redLed,HIGH);
digitalWrite(yellowLed,LOW);
digitalWrite(greenLed,LOW);
delay(200);
digitalWrite(redLed,LOW);
digitalWrite(yellowLed,HIGH);
digitalWrite(greenLed,LOW);
delay(200);
digitalWrite(redLed,LOW);
digitalWrite(yellowLed,LOW);
digitalWrite(greenLed,HIGH);
delay(200);
digitalWrite(redLed,LOW);
digitalWrite(yellowLed,LOW);
digitalWrite(greenLed,LOW);
delay(200);
}
--------------------------------------------------------------------
BUTON İLE RENK DEĞİŞTİRME
int redLed =2;
int yellowLed =3;
int greenLed =4;
int buton=9;
void setup() {
pinMode(redLed,OUTPUT);
pinMode(yellowLed,OUTPUT);
pinMode(greenLed,OUTPUT);
pinMode(buton,INPUT);
}
void loop() {
if (digitalRead(buton)==HIGH)
{
digitalWrite(redLed,HIGH);
digitalWrite(yellowLed,LOW);
digitalWrite(greenLed,LOW);
} else
{
digitalWrite(redLed,LOW);
digitalWrite(yellowLed,LOW);
digitalWrite(greenLed,HIGH);
}
}