const int pins[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
const int joystickPin = 28; // Пін, на якому підключений джойстик
int counter = 0;
void setup() {
for (int i = 0; i < 10; i++) {
pinMode(pins[i], OUTPUT);
}
}
void loop() {
// Отримуємо значення з джойстика
int joystickValue = analogRead(joystickPin);
// Перетворюємо значення джойстика (0-1023) в діапазон для counter (0-1023)
counter = map(joystickValue, 0, 1023, 0, 1023);
// Виводимо значення counter на стовпчиковий індикатор
for (int i = 0; i < 10; i++) {
digitalWrite(pins[i], bitRead(counter, i) ? HIGH : LOW);
}
// Затримка залежить від положення джойстика
int delayTime = map(joystickValue, 0, 1023, 200, 20); // Чим менше значення, тим швидше відображення
delay(delayTime);
}