const int ledPin = 9; // LED chiroqning pin raqami
const int buttonUpPin = 2; // Tezligini oshirish uchun knopka pin raqami
const int buttonDownPin = 3; // Tezligini kamaytirish uchun knopka pin raqami
int ledSpeed = 100; // Boshlang'ich tezlik (ms)
const int speedStep = 10; // Tezlikni o'zgartirish uchun qadam
void setup() {
pinMode(ledPin, OUTPUT); // LED chiroqni chiqish sifatida sozlash
pinMode(buttonUpPin, INPUT); // Tezlikni oshirish knopkasi uchun kirish sifatida sozlash
pinMode(buttonDownPin, INPUT); // Tezlikni kamaytirish knopkasi uchun kirish sifatida sozlash
}
void loop() {
// Tezlikni o'zgartirish
if (digitalRead(buttonUpPin) == HIGH && ledSpeed > speedStep) {
ledSpeed -= speedStep;
}
// Tezlikni kamaytirish
if (digitalRead(buttonDownPin) == HIGH && ledSpeed < 1000) {
ledSpeed += speedStep;
}
// LED chiroqni yonish va o'chirish
digitalWrite(ledPin, HIGH);
delay(ledSpeed);
digitalWrite(ledPin, LOW);
delay(ledSpeed);
}