I am still learning how to use the arduino after finally getting it to work after 5 months.
I have an old Alalog steering wheel game controller with pedals (Mad Catz 5320) that I would eventually like to get working with the Arduino. The pedals are separate and I can easily hook them up to an analog pin. It works on 2 potentiometers in series. I guess it is a average value and pressing the break raises the resistance and pressing the gas lowers the resistance?
How would I be able to read the value and display it with LED brightness with blue for gas and red for break?
I was using this basic code just to test it.
#define LED 9 // the pin for the LED
int val = 0;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
val = analogRead(0);
analogWrite(LED, val/4)
delay(10);
}
Using a pull down resistor.Value reads 0. Pressing the gas I get 980. Pressing the break does nothing. Pressing on both brings it back to 0.
Using a pull up resistor. Value reads 1022. Pressing gas lowers to 46. Pressing Break does nothing. Pressing both brings it back to 1022.
int potVar = 0;
void setup() {
Serial.begin(9600);
pinMode(11, OUTPUT);
}
void loop() {
//read the voltage on the potentiometer:
potVar = analogRead(0);
//print the value out:
Serial.println(potVar, DEC);
//slight pause
delay(10);
//dim the LED. since the resolution of the input is 10bit and the output(1024)
//is only 8bit (255) we need to divide potVar by 4 to get the right range
analogWrite(11,potVar/4);
}
How are the pedals connected?
2 three connection pots? If so then you want to connect 5v to one side, gnd to the other and analog read to the centre connection.
Then you want to do two analog read commands with the map function to light up the LEDs
The multimeter shows a value of 41.3k ohms at rest. Pressing gas lowers it to 0 ohms. Pressing break raises it to 81.7k ohms. Pressing both pedals gives 40.4k ohms
Ok, yes I would have thought that you want 5v into the potentionmeter circuit and then the analog read pin reading from the output with a pull down resistor (maybe another pot so you can fiddle and calibrate/change it) going to ground also from the output.
Then use your serial monitor to find out what values you get.
If you just want it lighting up for each pedal then you can use 'if' commands to light up the LEDs on certain values. If you want to make then change brightness depending on pedal 'pressure' then you will need to use 'if' to decide whether it's high or low (which pedal it is), then use 'map' to change the value from the range the pedal gives, to 0-255 for PWM on the LED pin.