I`m trying to make a k-wire interface without the elm chip.(it is not av. in my country)
I used this schematic and info fromhttp://blog.perquin.com/blog/category/odbii/.
So, to init the k-wire (fast way) I need to :
Wait for 300ms with K line high.
Pull K line low for 25 +/- 1 ms
Let K line rise high and wait 25ms
init serial connection to 10400 baud, 8N1, 1=0Volt 0=12Volt, least significant bit first
wait for response 83 f1 01 c1 e9 8f ae 01=physical address, c1=response ok (7f=fail), e9=kb1, 8f=kb2
My idea was
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void fastinit(){
Serial.println("F init start");
digitalWrite(11,HIGH);
delay(299);//(fast init 300 ms)
digitalWrite(11,LOW);
delay(25);
digitalWrite(11,HIGH);
delay(25);
mySerial.begin(10400);
mySerial.write("c1 33 f1 81 66");
Serial.println("F init end");
}
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Setup");
fastinit();
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}