Go Down

Topic: Simulating resistance for buttons (Read 1 time) previous topic - next topic


OK. I'm trying to interface my Arduino with a circuit for the steering wheel controls in my car.
I wrote a sketch that reads the input voltage, compares it to values for Volume Up, Volume Dn and Mode.
If it sees any of those three it does one thing (currently printing Vol Up, Vol Dn, or Mode on the screen via Serial Monitor),
otherwise it passes the voltage out on pin 9 using analogWrite to send a PWM voltage out.

However, I'm either doing something wrong, or exceeding the current capacity of Pin 9's output.

Here's the original diagram, and the modified one I was attempting to use.

It seems that I killed pin 9 somehow.

Here's the sketch I'm using:

Code: [Select]
int swcIn;                      //Set variable name for SWC reading
int swcOut;                     //Set variable name for SWC output
int swcPinin = 3;               //Set pin for SWC read
int swcPinout = 9;              //Set pin for SWC passthrough output

void setup()                    // run once, when the sketch starts
  Serial.begin(9600);           // Set up serial 

void loop()                     // run over and over again
  swcIn = analogRead(swcPinin); // look at SWC input pin, store it in swcIn

if ((swcIn >= 606) && (swcIn <= 609)) // is swcIn => 606 and =< 609?
      Serial.println ("Vol Dn");  //Yes? Print "Vol Dn" to serial monitor
else if ((swcIn >= 506) && (swcIn <= 509))  //Is swcIn =>506 and =< 509?
      Serial.println ("Vol Up");  //Yes? Print "Vol Up" to serial monitor                             
else if ((swcIn >= 317) && (swcIn <= 320))  //Is swcIn => 317 and =<320?
      Serial.println ("Mode");    // Yes? Print "Mode" to serial monitor
    analogWrite (swcPinout, (swcIn/4));  // otherwise pass signal to radio
//        delay(25);                     // wait long enough for radio to read it
        analogWrite (swcPinout, 255); // clear the pin so it doesn't keep sending the last command


The sketch seems to work fine.

Do I need to use different components?

I had thought about using an output per button, using a relay to simulate each button, but that wastes a lot of outputs. And I need something like 6 for the other part of the project.

When the wires were still intact, I measured the voltage for each switch. Here's what I got:

Vol Up  2.47V
Vol Dn  2.95V
Mute    1.99V
Mode   1.55V
Track Up  .42V
Track Dn  .95V
Answer  4.46V
Hang Up   3.98V
Voice  3.46

When the voltage is passed through on pin 9 via PWM, it matches up (it's actually about .2V higher, but the 5V from the Arduino is about .2V higher than the 4.98V the radio supplies. I can adjust for it in software.)

Any ideas?




your steering wheel is probably on a can or lin bus and is actually sending data to and form the on board control systems, and your meter isnt fast enough to react to the individual pulses ... none are capable of that.


Pin 9 is giving out PWM signals. In order to make that look like an analogue signal you need a filter, I don't see one.
Also check with a meter if the voltage on what you want to connect to pin 9 is not being pulled up to a higher voltage than 5V. That would kill it. If so you will have to use a transistor to buffer the signal.


Dec 01, 2012, 01:01 pm Last Edit: Dec 01, 2012, 01:30 pm by JayinMI Reason: 1
It is not being pulled higher than 5V, but it appears that the 5V coming out of the radio is overriding whatever voltage I try to send to it.
The SWC wires are not on a Can Bus or Lin Bus in this car.

Grumpy_Mike...can you point me in the direction of the filter I need?



Edit: You mean like a low-pass filter (inline resistor, cap across the two leads?)
Helps alot when you know what to search for. My previous efforts resulted in nada.

What it looks like is that I need to pass varying levels of ground, so whatever method I end up using I need to make sure that there is a path to ground for the circuit to work.


but it appears that the 5V coming out of the radio is overriding

That would be because the pin is being directly connected to the 5V and not through a resistor as you showed. So when you output zero volts from the arduino you are trying to short out this voltage. That is a way to make things melt.

It is a low pass filter you need. The simplest form is a resistor and capacitor.

Go Up