|
Rus svet yorugʻlik va yun phoros eltuvchi yorugʻlik signali beradigan elektr qurilma
|
bet | 2/2 | Sana | 15.05.2024 | Hajmi | 2,02 Mb. | | #235739 |
Bog'liq Aqilli Shahar 1.2DASTUR KODI
int pushButton = 2;
int led1 = 7;//авто
int led2 = 6;
int led3 = 5;
int led4 = 4;//пешеход
int led5 = 3;
void setup()
{
Serial.begin(9600);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(3, OUTPUT);
pinMode(pushButton, INPUT);
}
void loop() {
int buttonState = digitalRead(pushButton);
Serial.println(buttonState);
if (buttonState == HIGH) {
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
delay(3000);
digitalWrite(7, LOW);
delay(1000);
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
digitalWrite(6, LOW);
delay(1000);
digitalWrite(6, HIGH);
delay(1000);
digitalWrite(6, LOW);
delay(1000);
digitalWrite(6, HIGH);
delay(1000);
digitalWrite(3, LOW);
digitalWrite(6, LOW);
delay(50);
digitalWrite(5, HIGH);
digitalWrite(4, HIGH);
delay(5000);
digitalWrite(4, LOW);
delay(1000);
digitalWrite(5, LOW);
delay(1000);
digitalWrite(5, LOW);
digitalWrite(3, HIGH);
delay(50);
}
if (buttonState == LOW) {
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
}
}
Dastur link
https://www.tinkercad.com/things/favTWV6xWKt-copy-of-maket-svetofora-s-kodom
Xullosa
Dastur orqali hayotdagi real vaxt tizimida ishlaydigan qurilmalarning yasalish va dasturlash muhitini o’rgandik.
|
| |