T.C. Mİllî Eğİtİm BakanlIğI
İSTANBUL / PENDİK - Cahit Zarifoğlu Ortaokulu

Led Trafik Modülü

    

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

19-02-2020

 

 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);

  }

 

}

Paylaş Facebook  Paylaş twitter  Paylaş google  Paylaş linkedin
Yayın: 19.02.2020 - Güncelleme: 19.12.2024 12:08 - Görüntülenme: 372
  Beğen | 0  kişi beğendi