Trying to put together a control panel that'll act as a HID (for a simulator). I'm using momentary pushbuttons, a few toggle switches, and a couple of potentiometers. The pushbuttons and switches are sorted, but one of the potentiometers is giving me fits.
Basically using a slide potentiometer to read the voltage between 0 and 1023. That part I get. Using one slide pot, I can easily enough use it to zoom in and out:
Code: Select all
const int potPin0 = 0;
int val = 0;
void setup() {
Keyboard.begin();
}
void loop() {
static int oldPotState = analogRead(potPin0);
val = analogRead(potPin0);
if (val > (oldPotState + 100) || val < (oldPotState - 100)) {
if (val < (oldPotState - 100)) {
Keyboard.println("-");
} else if (val > (oldPotState1 + 100)) {
Keyboard.println("+");
}
oldPotState1 = val;
}
}
Any help is appreciated!