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:
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
}
else
{
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?
Thanks.
Jay