-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaddle_debug.ino
More file actions
70 lines (58 loc) · 1.78 KB
/
paddle_debug.ino
File metadata and controls
70 lines (58 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Paddle Connection Debug Test
// This sends MIDI messages to help diagnose wiring
// P2 = LEFT paddle (Dit) sends Note 1
// P0 = RIGHT paddle (Dah) sends Note 2
#include <DigiMIDI.h>
#define paddleLeft 2 // P2
#define paddleRight 0 // P0
#define LED 1 // P1
bool lastLeftState = false;
bool lastRightState = false;
void setup() {
pinMode(paddleLeft, INPUT_PULLUP);
pinMode(paddleRight, INPUT_PULLUP);
pinMode(LED, OUTPUT);
// Startup: 5 fast blinks
for (int i = 0; i < 5; i++) {
digitalWrite(LED, HIGH);
DigiMIDI.delay(80);
digitalWrite(LED, LOW);
DigiMIDI.delay(80);
}
DigiMIDI.delay(500);
}
void loop() {
DigiMIDI.update();
// Read paddles (INPUT_PULLUP means: LOW = pressed, HIGH = not pressed)
bool leftPressed = !digitalRead(paddleLeft); // Invert because of pullup
bool rightPressed = !digitalRead(paddleRight); // Invert because of pullup
// LEFT paddle changed
if (leftPressed != lastLeftState) {
if (leftPressed) {
// LEFT pressed - send Note 1 ON (velocity 100)
DigiMIDI.sendNoteOn(1, 100, 1);
digitalWrite(LED, HIGH);
} else {
// LEFT released - send Note 1 OFF (velocity 0)
DigiMIDI.sendNoteOn(1, 0, 1);
digitalWrite(LED, LOW);
}
lastLeftState = leftPressed;
DigiMIDI.delay(10); // Small debounce
}
// RIGHT paddle changed
if (rightPressed != lastRightState) {
if (rightPressed) {
// RIGHT pressed - send Note 2 ON (velocity 100)
DigiMIDI.sendNoteOn(2, 100, 1);
digitalWrite(LED, HIGH);
} else {
// RIGHT released - send Note 2 OFF (velocity 0)
DigiMIDI.sendNoteOn(2, 0, 1);
digitalWrite(LED, LOW);
}
lastRightState = rightPressed;
DigiMIDI.delay(10); // Small debounce
}
DigiMIDI.delay(1);
}