(I am Using ARDUINO UNO)
I am using a toggle Switch on Pin 2 and one on Pin 3 to Trigger pin 10 and 12
I want Pin 2 to control pin 10
SO when the Toggle Switch is Open on Pin 2 Pin 10 Will be off
then when the Toggle Switch in closed I want pin 10 to turn on.
and the Same for Pin 3 and 12.
This is a simple Turn signal circuit for a UTV which I am making street legal.
The problem is Pin 10 stay on continually.
I am using the following code where an I going wrong?
const int lftSW = 2; // Left Switch is on pin 2 of Arduino
const int rtSW = 3; // Right Switch is on pin 3 of Arduino
const int lftLED = 10; // Left LED Circuit is on pin 10 of Arduino
const int rtLED = 12; // Right LED Circuit is on Pin 12 of Arduino
void setup ()
{
pinMode (lftSW, INPUT);
pinMode (rtSW, INPUT);
pinMode (lftLED, OUTPUT);
pinMode (rtLED, OUTPUT);
}
void loop()
{
if (digitalRead(lftSW) == LOW)
{
TurnOn(lftLED);
}
if (digitalRead(rtSW) == LOW)
{
TurnOn(rtLED);
}
}
void TurnOn(int led)
{
for (int i=0;i<3;i++) // Flash Lights 3 times then delay
{
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
}
delay(100);
}
ZachBike_V2.ino (723 Bytes)