Steering wheel control

This is my first ever project with the Arduino. I have worked with basic stamp a bit.
So my project is this.
I just bought a new truck. I am putting a after market radio in my car. I need to control the radio with the steering wheel control.
I know they make boxes out there to do this. This is the box I am using http://retailer.installernet.com/productfeatures.aspx?retailerid=1273&productid=23230&sid=20B26D55-DA04-4B5D-A62C-6767C92FBC25
My problem is this.
I need to have 1 single button do two actions. For example. Phone button press will pick up a phone call. Hold Phone button and it would start voice recognition.
Since i dont know the protocol that the Pioneer unit uses I would need to use the ASWC box as well.
Steering controls------> Arduino -------->ASWC--------> Radio
Summarize
Arduino reads the resistance from the steering wheel control then sends a resistance valve to the ASWC box which then makes the radio function work.

Not sure where to start. I did buy a nano should be here tues
Thanks
Mike

no one can help me?

It is not at all clear why you want the arduino.
It is not at all clear what buttons you want to detect.
It is not clear what the arduino has to feed to the ASWC as this appeares to be a compleate solution.
It is not clear why the thread has this title.

Use a PNP transistor to drive a constant current of about 10 mA, into the resistance which is to be measured.

Connect the output to the pwm pin of arduino and get a value corresponding to the resistance value. use that value with a digital pin to operate your radio or whatever.

hope this resolves some of the issues in your problem.

int analogPin = 0;     // potentiometer wiper (middle terminal) connected to analog pin 3
                       // outside leads to ground and +5V
int raw = 0;           // variable to store the raw input value
int Vin = 5;           // variable to store the input voltage
float Vout = 0;        // variable to store the output voltage
float R1 = 10;         // variable to store the R1 value
float R2 = 0;          // variable to store the R2 value
float buffer = 0;      // buffer variable for calculation

void setup()
{
  Serial.begin(9600);             // Setup serial
  digitalWrite(13, HIGH);         // Indicates that the program has intialized
}

void loop()
{
  raw = analogRead(analogPin);    // Reads the Input PIN
  Vout = (5.0 / 1023.0) * raw;    // Calculates the Voltage on th Input PIN
  buffer = (Vin / Vout) - 1;
  R2 = R1 / buffer;
  Serial.print("Voltage: ");      //
  Serial.println(Vout);           // Outputs the information
  Serial.print("R2: ");           //
  Serial.println(R2);             //
  delay(1000);
}

I just copied and pasted this from the old forum... i want to try out this code now

Grumpy_Mike:
It is not at all clear why you want the arduino.
It is not at all clear what buttons you want to detect.
It is not clear what the arduino has to feed to the ASWC as this appeares to be a compleate solution.
It is not clear why the thread has this title.

  1. The arduinio will give me the function to have 1 button do 2 actions. quick press or hold press
  2. Vol up, Vol down, trk up, trk down, Seek up, seek down, Phone pickup, phone hang up, Voice activate and Mode
  3. The ASWC reads the Resistance there for I would need the arduino to create those Resistances and send them to the ASWC. The ASWC will only do one action per button.

I am not sure i can connect the arduino directly to the radio as i am not sure what the protocol is that the pioneer radio uses this is why the ASWC is in the picture

The ASWC reads the Resistance there for I would need the arduino to create those Resistances and send them to the ASWC.

In which case you need to use a digital pot to send the unit a resistance value.

Grumpy_Mike:

The ASWC reads the Resistance there for I would need the arduino to create those Resistances and send them to the ASWC.

In which case you need to use a digital pot to send the unit a resistance value.

http://arduino.cc/en/Tutorial/SPIDigitalPot

Thanks I have ordered some samples already.

The good news is I dont need the AWSC. The pioneer head unit just read resistance values.
As I am new this is the code i am starting with.

int analogPin = 4;     // potentiometer wiper (middle terminal) connected to analog pin 3
                       // outside leads to ground and +5V
int raw = 0;           // variable to store the raw input value
int Vin = 5;           // variable to store the input voltage
float Vout = 0;        // variable to store the output voltage
float R1 = 15;         // variable to store the R1 value
float R2 = 0;          // variable to store the R2 value
float buffer = 0;      // buffer variable for calculation

void setup()
{
  Serial.begin(9600);             // Setup serial
           // Indicates that the program has intialized
}

void loop()
{
  raw = analogRead(analogPin);    // Reads the Input PIN
  Vout = (5.0 / 1023.0) * raw;    // Calculates the Voltage on th Input PIN
  buffer = (Vin / Vout) - 1;
  R2 = R1 / buffer;
  Serial.print("Voltage: ");      //
  Serial.println(Vout);           // Outputs the information
  Serial.print("R2: ");           //
  Serial.println(R2);             //
  delay(1000);
if(( R2 > 21 ) && ( R2 < 23) )
{
digitalWrite(13, HIGH);
}
else
{
digitalWrite(13, LOW);
}
}

As R2 is a float then you will be lucky to get it into such a range.
Vin is an int and so needs casting as a float before doing sums with it.

Grumpy_Mike:
As R2 is a float then you will be lucky to get it into such a range.
Vin is an int and so needs casting as a float before doing sums with it.

You completely lost me there. Can you explain? Float?

themlruts:

Grumpy_Mike:
As R2 is a float then you will be lucky to get it into such a range.
Vin is an int and so needs casting as a float before doing sums with it.

You completely lost me there. Can you explain? Float?

He means the variable is of the float data type.

got it so i think i should covert the float to interger?

themlruts:
got it so i think i should covert the float to interger?

An unsigned integer would give you a much larger absolute value. Furthermore, negative ohm resistors are hard to come by. :wink:

Can anyone help write the case statements for this?

For what? It dosn't look like a case statement is sutiable here.

Grumpy_Mike:
For what? It dosn't look like a case statement is sutiable here.

Mike i was thinking that i could used case for the different resistances I was looking for. If you look at my first post those are the Resistances i need to detect

The thing is that if you do an analogue measurement you are not going to get a precise repeatable result.
A case statement will only work with integers and not with ranges. What you need to do is to have a look up table (an array) with a range of values in it. Then search through the array until you find the entry that fits your value. Then use that array entry number in the case statement.

However, if you only have a few values then use a sequence of if statements with two values, greater than and less than like you had but with a much greater range. Do some measurements and print them out to get an idea of the real values, then set the range limits between the readings you get.

Grumpy_Mike:
The thing is that if you do an analogue measurement you are not going to get a precise repeatable result.
A case statement will only work with integers and not with ranges. What you need to do is to have a look up table (an array) with a range of values in it. Then search through the array until you find the entry that fits your value. Then use that array entry number in the case statement.

However, if you only have a few values then use a sequence of if statements with two values, greater than and less than like you had but with a much greater range. Do some measurements and print them out to get an idea of the real values, then set the range limits between the readings you get.

How would you recommend doing it? Can I measure it digitally instead? I want to make the code as streamed line as i can so it is responsive

Take the output of the switch and connect it between an analogue input pin and ground, have a pull resistor from the input to +5V of approximately one quarter of the maximum resistance you get from pushing the buttons.
Then make a note of the values you read when pushing all the buttons.