Hello folks!
We have been making slow progress on the ACC Handle code for Arduino. I`m using a Leonardo and so far we have a stable way of reading the ACC Values.
With the code below we can Serial Print and read the values. Next step will be stopping the loop and adding keyboard.Print commands.
Credits to Arduino Forum User UKHeliBob !!
// Arduino Leonardo Rev3.0
// This code is for all Scania 4-Series
// ACC HID control for ETS2
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int analogValue = analogRead(A0);
// print out the value you read:
Serial.println(analogValue);
delay(100); // delay in between reads for stability
if (analogValue > 870 && analogValue < 890) // read the analogue input into variable analogValue
{
//ACC is in the OFF Pos
Serial.print("ACC OFF");
delay(1);
}
else
if (analogValue > 950 && analogValue < 965)
{
//ACC is in the ON Pos
Serial.print("ACC ON");
delay(1);
}
else
if (analogValue > 985 && analogValue < 995)
{
//ACC is in the ON Pos and RET is Pressed
Serial.print("ACC ON+RET");
delay(1);
}
else
if (analogValue > 1000 && analogValue < 1011)
{
//ACC is in the ON Pos and RES is Pressed
Serial.print("ACC ON+RES");
delay(1);
}
else
if (analogValue > 1012 && analogValue < 1025)
{
//ACC is in the ON Pos and ACC is Pressed
Serial.print("ACC ON+ACC");
delay(1);
}
}
// Jeroen van der Velden
// https://hackaday.io/project/8448-real-dashboard-truck-simulator
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.