My first project should be relatively simple:
L Indicator on - L fog light on (2 seconds delay after indicator off)
R indicator on - R fog light on (2 seconds delay after indicator off)
Obviously there is no way Arduino could power car fog lights :-), so system will run on two relays (for L and R fog lamp) capable to handle 12V electric instalation.
Indicator circuits (L and R) would be equipped with a step down V regulator, to produce stable 5V to send signal to Arduino. This system must be reliable, as I intend to fit it ito my car!
So..
I wrote my first advanced sketch 8):
int ledA = 8;
int ledB = 7;
int switchLeft = A0;
int SwitchRight = A5;
void setup()
{
pinMode(ledA, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(switchLeft, INPUT);
pinMode(SwitchRight, INPUT);
}
void loop()
{
if (digitalRead(switchLeft) == HIGH)
{
digitalWrite(ledA, HIGH);
}
else
{
digitalWrite(ledA,LOW);
}
if (digitalRead(SwitchRight) == HIGH)
{
digitalWrite(ledB, HIGH);
}
else
{
digitalWrite(ledB,LOW);
}
}
It is working! But not exactly as desired.
First of all - LEDs are staying on after removing 5V from: A0 - for 4 seconds - and for 2 seconds, after disconnecting A5
Second problem - even a simple finger tap at analog bank will start a diode (or both diodes) to switch ON.
Any ideas?
This is my second day of playing with Arduino - dont shout me if I've made some stupid mistakes....
All the best!
Hants