Beruflich Dokumente
Kultur Dokumente
Take old style steering controls and convert to JVC car audio infra red based
signals over wire
Early Land Rover Discovery base and mid line radios used simple press button f
unctions on the steering control (not resistor based),
so this just detects a button push and build the appopriate RC signal - if you
want to change to resistor based then amend the code between the ########### co
mments
The code allows each button to have four functions, single click, double click
, long press and very long press, though I cant find an effective use for very l
ong press, perhaps power off)
It is assumed that only one button at a time is to be processed, simultaneous
pressing of different buttons gives odd effects, usually as a double click on t
he last button pressed.
I scanned the wire for all available codes and found some to do Bluetooth Call
functions and some other odd ones that do testing/diagnostics. I have coded all
the functions that came up except the test ones
and not allocated every one to a button press.
Also kept only volume related functions on the volume control buttons so that
you don't accidently blast your eardrums when wanting to change a music station
etc.
Vol
Vol
Vol
Vol
+
+
+
+
Vol
Vol
Vol
Vol
Waveband
Waveband
Waveband
Waveband
Tune
Tune
Tune
Tune
control
control
control
control
control
control
control
control
Change Source
Answer BT call
call
- no function
Connections
Pin 4: + from vol + control
Pin 5: - from vol - control
Pin 6: + from Waveband control
Pin 7: + from Tune control
Pin 8: to circuit controlling blue remote wire
GND - common ground from steering controls
I used an Optocoupler to seperate the 5v and 12v circiuits
Note that you do NOT feed power to the radio remote steering wire but rather g
round it to generate a signal
pin 8 to the feed of the coupler, and ground to the Arduino on the input side
Collector to blue/yellow wire
Emmiter to radio common ground 12V
To use this you need a 12v to 5v power converter to power the arduino, it make
s life easier if you use the female equivalent connector of the Land rover steer
ing controls
_0 OUTPUT
_1 INPUT
jvc 2
dataDelay 537
int BPVirt = 0;
int adddouble = 4;
le click event
int addhold = 8;
event
int VolUB = 4;
int VolDB = 5;
int WaveB = 6;
int TuneB = 7;
int ConOut = 1;
int PINO = 8;
int Length = 537;
int IncomingByte = 0;
int Reps = 3;
int b = 0;
etected
int buttonPin= 0;
to 7)
int i = 0;
Initialisation
void setup() {
pinMode(PINO, OUTPUT);
pinMode(VolUB, INPUT);
pinMode(VolDB, INPUT);
pinMode(WaveB, INPUT);
pinMode(TuneB, INPUT);
digitalWrite(PINO, LOW); // Make PIN low to shut off transistor
Serial.begin(9600);
Serial.println("1 - Volume Up");
Serial.println("2
Serial.println("3
Serial.println("4
Serial.println("5
Serial.println("6
Serial.println("7
Serial.println("8
Serial.println("9
}
//
Volume Down");
Source");
Sound");
Mute");
Skip Fwd");
Skip Back");
Skip Fwd Hold");
Skip Back Hold");
void loop() {
if (Serial.available() > 0) {
ConOut = 1;
}
BPVirt = 0;
// check if and which button has been pressed #####################
if (digitalRead(VolUB) == HIGH) {
buttonPin = 4;
digitalWrite(buttonPin, HIGH );
}
if (digitalRead(VolDB) == HIGH) {
buttonPin = 5;
digitalWrite(buttonPin, HIGH );
}
if (digitalRead(WaveB) == HIGH) {
buttonPin = 6;
digitalWrite(buttonPin, HIGH);
}
if (digitalRead(TuneB) == HIGH) {
buttonPin = 7;
digitalWrite(buttonPin, HIGH );
}
// end of button check
####################
if (buttonPin !=0) {
b = checkButton();
if (b == 1) clickEvent();
if (b == 2) doubleClickEvent();
if (b == 3) holdEvent();
if (b == 4) longHoldEvent();
}
b = 0;
switch (BPVirt) {
case 4: // vol up, single click
AGC();
sendCommand(0x04, 1);
break;
case 5: //vol down, single click
AGC();
sendCommand(0x05, 1);
break;
case 6: //source select, single click
AGC();
sendCommand(0x08, 1);
break;
case 7: //next, single click
AGC();
sendCommand(0x12, 1);
break;
case 8: // vol up, double click
AGC();
sendCommand(0x04, 0);
sendCommand(0x04, 0);
sendCommand(0x04, 1);
break;
case 9: //vol down, double click
AGC();
sendCommand(0x06, 1);
break;
case 10: //EQ select, double click
AGC();
sendCommand(0x0C, 1);
break;
case 11: //next, double click
AGC();
sendCommand(0x13, 1);
break;
case 12: // vol up, hold
break;
case 13: //vol down, hold
AGC();
sendCommand(0x00, 1);
break;
case 14: //source select, hold
break;
case 15:
break;
default:;
}
BPVirt = 0;
/* For testing - check if input from console (bypass buttons), if so send
output to console too */
/*if (Serial.available() > 0) {
IncomingByte = Serial.read();
ConOut = 1;
switch (IncomingByte) {
case '1':
JVCVolUp();
break;
case '2':
JVCVolDn();
break;
case '3':
JVCSource();
break;
case '4':
JVCSound();
break;
case '5':
JVCMute();
break;
case '6':
JVCSkipFwd();
break;
case '7':
JVCSkipBack();
break;
case '8':
JVCSkipFwdHold();
break;
case '9':
JVCSkipBackHold();
break;
default:;
}*/
}
//
int checkButton()
{
/* int event = 0; */
event = 0;
// Read the state of the button
buttonVal = digitalRead(buttonPin);
// Button pressed down
if (buttonVal == HIGH && buttonLast == LOW && (millis() - upTime) > debounce) {
downTime = millis();
ignoreUp = false;
waitForUp = false;
singleOK = true;
holdEventPast = false;
longHoldEventPast = false;
if ((millis()-upTime) < DCgap && DConUp == false && DCwaiting == true) DConUp =
true;
else DConUp = false;
DCwaiting = false;
}
// Button released
else if (buttonVal == LOW && buttonLast == HIGH && (millis() - downTime) > debou
nce) {
if (not ignoreUp) {
upTime = millis();
if (DConUp == false) DCwaiting = true;
else {
event = 2;
DConUp = false;
DCwaiting = false;
singleOK = false;
}
}
}
// Test for normal click event: DCgap expired
if ( buttonVal == LOW && (millis()-upTime) >= DCgap && DCwaiting == true && DCon
Up == false && singleOK == true) {
event = 1;
DCwaiting = false;
}
// Test for hold
if (buttonVal == HIGH && (millis() - downTime) >= holdTime) {
// Trigger "normal" hold
if (not holdEventPast) {
event = 3;
waitForUp = true;
ignoreUp = true;
DConUp = false;
DCwaiting = false;
//downTime = millis();
holdEventPast = true;
}
// Trigger "long" hold
if ((millis() - downTime) >= longHoldTime) {
if (not longHoldEventPast) {
event = 4;
longHoldEventPast = true;
}
}
}
buttonLast = buttonVal;
return event;
}