5. 1-svetodioda bir marta o’chib yonadi, 2-svetodiodda ikki marta o’chib yonadi si sakkiz marta. Amaliy qism


Download 18.86 Kb.
Sana07.01.2023
Hajmi18.86 Kb.
#1082101
Bog'liq
Kurbonov D 2-mustaqil ish


O`ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI


MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI
UNIVERSITETI SAMARQAND FILIALI

2-labaratoriya ishi


Bajardi:Kurbonov D.


Tekshirdi : Primova X.


5. 1-svetodioda bir marta o’chib yonadi, 2-svetodiodda ikki marta o’chib yonadi ........ 8-si sakkiz marta.


Amaliy qism:

int ledPin = 13;


int ledState = LOW;
int k = 0;
unsigned long previousMillis = 0;
unsigned long currentMillis;
long OnTime = 800;
long OffTime = 300;
bool state =0;
bool flag = false;
uint32_t btnTimer = 0;
int ledrun;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(7, INPUT_PULLUP);
}
void loop() {
bool btnState = !digitalRead(7);
if (btnState && !flag && millis() - btnTimer > 100) {

flag = true;


btnTimer = millis();
ledrun = 1;
}
if (!btnState && flag && millis() - btnTimer > 100) {
flag = false;
btnTimer = millis();
ledrun = 0;
}

if(ledrun == 1 ){


unsigned long currentMillis = millis();
if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
{
ledState = LOW;
previousMillis = currentMillis;
digitalWrite(ledPin, ledState);
k++;
if (k > 2 ) state =1; }
else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime) && !state)
{
ledState = HIGH;
previousMillis = currentMillis ;
digitalWrite(ledPin, ledState);
}
}
}
Download 18.86 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling