This Arduino Leonardo sketch is the software core of a DIY Octapad-style controller. It reads the configured sensor and switch inputs and uses the Leonardo’s native USB keyboard support to send control events to compatible software. Review the pin assignments and key mapping in the sketch before connecting hardware.
The code below is preserved from the original build. Use the board and input wiring shown in your project diagram, then test each sensor individually before connecting the full pad set.
Setup notes
- Select Arduino Leonardo as the target board when compiling.
- Use a USB data cable and confirm the receiving application accepts the expected keyboard events.
- Check sensor polarity, pull-up wiring and input ranges before powering the circuit.
See the Arduino Leonardo documentation for board and USB capabilities.
Arduino Leonardo Mobile Octapad Code
Here Is the Code:
.jpg)
#include <Keyboard.h>
void setup(){
Keyboard.begin();
pinMode (10, INPUT_PULLUP);
pinMode (11, INPUT_PULLUP);
}
void loop() {
int c = analogRead(A0);
int d = analogRead(A1);
int e = analogRead(A2);
int f = analogRead(A3);
int g = analogRead(A4);
int h = analogRead(A5);
int i = analogRead(A6);
int j = analogRead(A7);
//8 pad selections------------------------------------------------------------
if(c>100){
Keyboard.print("q");
delay(10);
}
if(d>100){
Keyboard.print("w");
delay(10);
}
if(e>100){
Keyboard.print("e");
delay(10);
}
if(f>100){
Keyboard.print("r");
delay(10);
}
if(g>100){
Keyboard.print("s");
delay(10);
}
if(h>100){
Keyboard.print("d");
delay(10);
}
if(i>100){
Keyboard.print("u");
delay(10);
}
if(j>100){
Keyboard.print("x");
delay(10);
}
//Tone Selection Keys---------------------------------------------------------------------
if(!digitalRead(10)){
Keyboard.press(KEY_UP_ARROW);
delay(200);
} else if(!digitalRead(11)){
Keyboard.press(KEY_DOWN_ARROW);
delay(200);
}
Keyboard.releaseAll();
}
Comments
Post a Comment