Hi.
This is my version of the adapter between Toyota Corolla and Pioneer MHV-285BT.
Resistance correspondence table
The schematic
And the sketch
/*
Adapt steering wheel audio controls from Toyota Corolla to
Pioneer hud.
Tested on Corolla G10 with Pioneer MVH-285BT (3.3V @ 10kohms)
Author: Gatul - November 2020
*/
const int NO_BTN = 0;
const int MODE_BTN = 3;
const int NEXT_BTN = 4;
const int PREV_BTN = 5;
const int VOLUP_BTN = 6;
const int VOLDWN_BTN = 7;
const int PIN_MODEBTN = 2; // [MODE] input
const int PIN_SWCTRL = A0; // [^][v][+][-] input
const int PIN_LED = LED_BUILTIN;
const unsigned long DEBOUNCER_TIME = 50;
int decode_analog_btn(int adcValue){
if(adcValue <= 130) return NEXT_BTN;
if(adcValue >= 145 && adcValue <= 225) return PREV_BTN;
if(adcValue >= 285 && adcValue <= 365) return VOLUP_BTN;
if(adcValue >= 525 && adcValue <= 605) return VOLDWN_BTN;
return NO_BTN;
}
int get_button() {
static int lastButton = NO_BTN;
static bool btnPressed = false;
int analogButton = decode_analog_btn(analogRead(PIN_SWCTRL));
int digitalButton = digitalRead(PIN_MODEBTN);
if(digitalButton && !analogButton) {
btnPressed = false;
lastButton = NO_BTN;
}
else {
if(!btnPressed) {
btnPressed = true;
delay(DEBOUNCER_TIME);
if(!digitalButton) {
if(digitalRead(PIN_MODEBTN) == digitalButton) {
lastButton = MODE_BTN;
}
}
else { // boton analogico pulsado
if(decode_analog_btn(analogRead(PIN_SWCTRL)) == analogButton) {
lastButton = analogButton;
}
}
}
}
return lastButton;
}
void send_remote_command(int newBtn, int oldBtn) {
byte ledStatus = HIGH;
if(newBtn == NO_BTN) {
pinMode(oldBtn, INPUT);
ledStatus = LOW;
}
else pinMode(newBtn, OUTPUT);
digitalWrite(PIN_LED, ledStatus);
}
void setup() {
pinMode(PIN_LED, OUTPUT);
DDRD &= B00000011; // D2 a D7 INPUT
PORTD &= B00000111; // D3 a D7 LOW
// para reducir ruido ADC...
DDRC |= B00111110; // A1 a A5 OUTPUT
PORTC &= B11000001; // A1 a A5 LOW
}
void loop() {
static int oldButton = NO_BTN;
int newButton = get_button();
if(newButton != oldButton) {
send_remote_command(newButton, oldButton);
oldButton = newButton;
}
}
My full post (in spanish)
Regards

