Axiometa
Button D-Pad
Button D-Pad
SKU:AX22-0016
Low stock: 5 left
Regular price
$3.49
Regular price
Sale price
$3.49
Unit price
per
Taxes included.
Shipping calculated at checkout.
Couldn't load pickup availability

Technical Details
Pinout
Arduino Example Snippet
#define DPAD_PIN 1
int debounce = 150;
void setup() {
Serial.begin(9600);
}
void loop() {
int button = readAnalogButton();
if (button == 0) {
// No button pressed
} else if (button == 1) {
Serial.println("CENTRE");
delay(debounce);
} else if (button == 2) {
Serial.println("RIGHT");
delay(debounce);
} else if (button == 3) {
Serial.println("UP");
delay(debounce);
} else if (button == 4) {
Serial.println("DOWN");
delay(debounce);
} else if (button == 5) {
Serial.println("LEFT");
delay(debounce);
}
}
int readAnalogButton() {
int val = analogRead(DPAD_PIN);
if (val > 3600) return 0; // NOTHING (4095)
else if (val > 2750) return 5; // LEFT (3170)
else if (val > 2000) return 1; // CENTRE (2333)
else if (val > 1150) return 3; // UP (1555)
else if (val > 350) return 4; // DOWN (760)
else return 2; // RIGHT (0)
}