I created a blinker code and a momentary push button activating a relay for a 12 v horn code to make a UTV street legal.
The problem is when I try to combine them together I receive errors.
The error code I get is
Arduino: 1.8.5 (Windows 10), Board: “Arduino/Genuino Uno”
C:\Users\Matt\Documents\Arduino\ZachTurn_Signal\ZachTurn_Signal.ino\ZachTurn_Signal.ino.ino: In function ‘void loop()’:
ZachTurn_Signal.ino:41: error: ‘TurnOn’ was not declared in this scope
TurnOn(lftLED);
^
ZachTurn_Signal.ino:46: error: ‘TurnOn’ was not declared in this scope
TurnOn(rtLED);
^
ZachTurn_Signal.ino:50: error: a function-definition is not allowed here before ‘{’ token
{
^
ZachTurn_Signal.ino:63: error: expected ‘}’ at end of input
}
^
exit status 1
‘TurnOn’ was not declared in this scope
This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.
How do I combine codes successfully?
Thank You
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
const int button1 = 4;
const int relay1 = 11;
int buttonState1 = 0;
void setup() {
pinMode(relay1, OUTPUT);
pinMode(button1, INPUT_PULLUP);
pinMode (lftSW, INPUT_PULLUP);
pinMode (rtSW, INPUT_PULLUP);
pinMode (lftLED, OUTPUT);
pinMode (rtLED, OUTPUT);
}
void loop()
{
buttonState1 = digitalRead(button1);
if (buttonState1 == LOW) {
digitalWrite(relay1, LOW);
delay (1000);
} else {
digitalWrite(relay1, HIGH);
}
{
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(150);
digitalWrite(led, LOW);
delay(150);
}
delay(150);
}
}
utv_V4.ino (737 Bytes)
Horn.ino (541 Bytes)