| Тип джойстика | Аналоговый |
| Количество осей | 2 |
| Тип подключения | Шилд |
| Совместимость | Arduino Uno, Arduino Mega |
| Напряжение питания | 5V |
VCC → 5V GND → GND VRx → A0 VRy → A1 SW → D2
#include <Arduino.h>
const int xPin = A0;
const int yPin = A1;
const int buttonPin = 2;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
int x = analogRead(xPin);
int y = analogRead(yPin);
int buttonState = digitalRead(buttonPin);
Serial.print("X: ");
Serial.print(x);
Serial.print(" Y: ");
Serial.print(y);
Serial.print(" Button: ");
Serial.println(buttonState);
delay(100);
}
Отзывов пока нет. Будьте первым!