I am working on a set of foot pedals to help me in my photo editing. i have a set of foot pedals from a driving wheel which is broken so i have taken them apart and added an extra button as well as the 2 analog pedals.
this code is for my arduino compatiable teensy hid device
const int analogPin = A0;
const int analogPin1 = A1; // pin that the sensor is attached to
const int pinBtnUp = 20;
const int ledPin = 6; // pin that the LED is attached to
const int threshold = 900; // an arbitrary threshold level that's in the range of the analog input
const int threshold1 = 200;
boolean boolBtnUp;void setup() {
pinMode(ledPin, OUTPUT);
pinMode( pinBtnUp, INPUT_PULLUP );
boolBtnUp = false;
}void loop() {
int analogValue = analogRead(analogPin);
if (analogValue > threshold) {
digitalWrite(ledPin, HIGH);
Keyboard.set_key1( KEY_R );
}
else {
digitalWrite(ledPin,LOW);
Keyboard.set_key1( 0 );
}int analogValue1 = analogRead(analogPin1);
if (analogValue1 < threshold1) {
digitalWrite(ledPin, HIGH);
Keyboard.set_key1( KEY_L );
}
else {
digitalWrite(ledPin,LOW);
Keyboard.set_key1( 0 );
}boolean boolBtnUp = !digitalRead(pinBtnUp);
if ( boolBtnUp) {
digitalWrite(ledPin, HIGH);
Keyboard.set_key1( KEY_UP );
}
else {
digitalWrite(ledPin,LOW);
Keyboard.set_key1( 0 );
}Keyboard.send_now();
}
the PB works but the 2 analog ones dont!. the led lights up whenever i press either of the pedals or the switch but the keypress is not triggered!(when i press the pedals the led lights dimmer than when i press the switch).
For some reason one of the pedals reads 1023 to 0 when you press it and the other reads 0-1023!
thanks in advance