Zkoušel někdo realizovat přes arduino komfortní blikání(trippling) do auta?
U starších aut dodělání 3x bliknutí blinkru pouze klepnutím do páčky.
Na zahraničním foru jsem našel pouze tento program , ale nedaří se mi to rozchodit
Kód: Vybrat vše
#include <TimerOne.h>
int leftTurnSignal = 3;
int rightTurnSignal = 2;
int leftcommand = 6;
int rightcommand = 7;
int convenientlength = 270; // indirectly defines number of turn signal blinks. It is defined by length of time (set it for your car accordingly)
int convtimedetector = 28; // time needed to detect convenient MODE. If handle is pressed shortet than this time, system goes into convenient MODE, if not it will act as a normal blinking.
int counter = 0;
boolean starttime = false;
boolean leftactivated = false;
boolean rightactivated = false;
void setup()
{
Timer1.initialize(10000); // Timer1 length is 10000us which triggers the interrupt every 0.01 sec
Timer1.attachInterrupt(timerIsr); // enable Timer1 interrupt
pinMode(leftcommand, INPUT);
pinMode(rightcommand, INPUT);
pinMode(leftTurnSignal, OUTPUT);
pinMode(rightTurnSignal, OUTPUT);
}
void loop()
{
if (digitalRead(leftcommand) == 1 && digitalRead(rightcommand) == 0) leftactivated = true;
if (digitalRead(rightcommand) == 1 && digitalRead(leftcommand) == 0) rightactivated = true;
//Left Turn Signal Control
//=========================
if (leftactivated == true)
{
rightactivated = false;
digitalWrite(leftTurnSignal, HIGH);
starttime = true;
delay(30);
if (counter >= convtimedetector)
{
if (digitalRead(leftcommand) == 0)
{
while (counter <= convenientlength && digitalRead(rightcommand) != 1) //This is the place where CONVENIENT MODE for the left turn signal starts.
{
leftactivated = false;
}
digitalWrite(leftTurnSignal, LOW);
starttime = false;
counter = 0;
delay(100);
}
else
{
while (digitalRead(leftcommand) == 1)
{
//digitalWrite(leftTurnSignal, HIGH);
starttime = false;
leftactivated = false;
}
digitalWrite(leftTurnSignal, LOW);
starttime = false;
delay(100);
}
}
}
//Right Turn Signal Control
//==========================
if (rightactivated == true)
{
leftactivated = false;
digitalWrite(rightTurnSignal, HIGH);
starttime = true;
delay(30);
if (counter >= convtimedetector)
{
if (digitalRead(rightcommand) == 0)
{
while (counter <= convenientlength && digitalRead(leftcommand) != 1) //This is the place where CONVENIENT MODE for the right turn signal starts.
{
rightactivated = false;
}
digitalWrite(rightTurnSignal, LOW);
starttime = false;
counter = 0;
delay(100);
}
else
{
while (digitalRead(rightcommand) == 1)
{
//digitalWrite(rightTurnSignal, HIGH);
starttime = false;
rightactivated = false;
}
digitalWrite(rightTurnSignal, LOW);
starttime = false;
delay(100);
}
}
}
}
/// --------------------------
/// Custom ISR Timer Routine
/// --------------------------
void timerIsr()
{
if (starttime == true) ++counter;
if (starttime == false) counter = 0;
}