MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI
UNIVERSITETI SAMARQAND FILIALI
"O’rnatilgan tizimlar” fanidan
Bajardi: KIS102-19 - guruh talabasi
Muxtorov B.
Qabul qildi: Saidqulov E.
SAMARQAND – 2023
2-labaratoriya ishi
7.Knopka bosib turilganda o’ngdan chapga 8ta svetadiod ketma-ket yonib borishi va qo’yib yuborilganda teskari yo’nalishda xuddi shunday ishlashi kerak.
const int LED=10;
const int BUTTON=2;
int tekButton = LOW;
int prevButton = LOW;
boolean ledOn = false;
void setup()
{
pinMode (LED, OUTPUT);
pinMode (BUTTON, INPUT);
}
boolean debounce(boolean last)
{
boolean current = digitalRead(BUTTON);
if (last != current)
{
delay(5);
current = digitalRead(BUTTON);
return current; }
}
void loop()
{
tekButton = debounce(prevButton);
if (prevButton == LOW && tekButton == HIGH)
{
ledOn = !ledOn;
}
prevButton = tekButton;
digitalWrite(LED, ledOn);
Dostları ilə paylaş: |