Add paddle sketch for Arduino

This commit is contained in:
Marek S. Łukasiewicz 2026-02-08 12:45:16 +01:00
parent ad7ba0ce02
commit 8783d4f43e

27
paddle/paddle.ino Normal file
View file

@ -0,0 +1,27 @@
const int dot_pin = 2;
const int dash_pin = 3;
char last_state = 'X';
void setup() {
Serial.begin(115200);
pinMode(dot_pin, INPUT_PULLUP);
pinMode(dash_pin, INPUT_PULLUP);
}
void loop() {
char current_state = '0';
if (digitalRead(dot_pin) == LOW) {
current_state += 1;
}
if (digitalRead(dash_pin) == LOW) {
current_state += 2;
}
if (current_state != last_state) {
Serial.print(current_state);
last_state = current_state;
}
delay(1); // Limit update rate under 1kHz
}