Skip to content

Instantly share code, notes, and snippets.

@olii
Created September 28, 2016 12:18
Show Gist options
  • Save olii/56c874f41b649496672b34da8177ee7e to your computer and use it in GitHub Desktop.
Save olii/56c874f41b649496672b34da8177ee7e to your computer and use it in GitHub Desktop.
vwcdavr nano v3, cd changer emulator
// Copyright http://www.audi-a6.com.ua/viewtopic.php?f=30&t=5557&start=20#p127185
// Tested with Arduino Nano v3 Atmega328p
// Head unit tested: Skoda Symphony CD
// Connect pin 11 with DataIn
// pin 13 with Clock
// Gnd to Gnd
// no need to connect DataOut unless you need advanced features
// Активация линейного входа на Audi Concert
// Подключение Магнитола/Arduino
// DataIn (13) - Arduino 11
// Clock (15) - Arduino 13
// CDC Pilot Line (17) - Arduino VCC
// Дополнительно необходимо соеденить массу магнитолы с разъемом GND Arduino
#include <SPI.h>
void send_package(uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, uint8_t c6, uint8_t c7);
void setup() {
// put your setup code here, to run once:
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE1);
SPI.setClockDivider(SPI_CLOCK_DIV128); //62.5kHz@8Mhz 125kHz@16MHz
send_package(0x34,0xBE,0xFE,0xFF,0xFF,0xFF,0xFA,0x3C); //load disc
delay(1000);
send_package(0x74,0xBE,0xFE,0xFF,0xFF,0xFF,0x8F,0x7C); //idle
delay(100);
}
void loop() {
// put your main code here, to run repeatedly:
send_package(0x74,0xBE,0xFE,0xFF,0xFF,0xFF,0x8F,0x7C);
delay(500);
}
void send_package(uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, uint8_t c6, uint8_t c7)
{
SPI.transfer(0x34);
delayMicroseconds(750);
SPI.transfer(c1);
delayMicroseconds(750);
SPI.transfer(c2);
delayMicroseconds(750);
SPI.transfer(c3);
delayMicroseconds(750);
SPI.transfer(c4);
delayMicroseconds(750);
SPI.transfer(c5);
delayMicroseconds(750);
SPI.transfer(0xCF);
delayMicroseconds(750);
SPI.transfer(c7);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment