So this is my first post, so formal introduction, my name is Tony, I'm a junior at Purdue. I built an electric motorcycle, starting from just the frame. I'm (attempting) to use an Arduino for the turn signals. Pretty simple plan, I'll give the turn signal switch +5V, have two pins (left and right ) as digital inputs and then two digital outputs to MOSFETs to blink them. Figured it'd be simple....... it never is. I'm hoping this is one of those times where the author stares at code for hours and can't figure it out and the next person, at first glance, figures it out. Here's the code, I commented the crap out of it:
// Turn Signal Program
#define Left 13 // This pin is assigned to turn on the left turnsignal
#define Right 12 // This pin is assigned to turn on the right turnsignal
#define Leftin 8 // This is a 5V input pin for the left side
#define Rightin 4 // This is a 5V input pin for the right side
int valleft = 0; // Stores the state of the left input pin
int valright = 0; // Stores the state of the right input pin
int t = 500
void setup() {
pinMode(Left, OUTPUT); // This sets the left pin 13 as an output
pinMode(Right, OUTPUT); // This sets the right pin 12 as an output
pinMode(Leftin, INPUT); // This sets the leftin pin 8 as an input
pinMode(Rightin, INPUT); // This sets the rightin pin 7 as an input
}
void loop() {
{
val = digitalRead(Leftin); // Reads the leftin value and stores it
// check is the input is HIGH
if (valleft == HIGH) {
digitalWrite(Left, HIGH); // turns left turn signal on
delay(t);
digitalWrite(Left, LOW);
delay(t);
}
else {
digitalWrite(Left, LOW);
}
}
{
val = digitalRead(Rightin); // Reads the leftin value and stores it
// check is the input is HIGH
if (valright == HIGH) {
digitalWrite(Right, HIGH); // turns left turn signal on
delay(t);
digitalWrite(Right, LOW);
delay(t);
}
else {
digitalWrite(Right, LOW);
}
}
}
My error is "error: expected unqualified-id before numeric constant In function 'void loop()':" and it highlights line 6; "#define Rightin 4 // This is a 5V input pin for the right side" Any help would be greatly appreciated, I can't see anything wrong with it....unless....can I do two loops like that? I've never needed two separate loops, as embarrassing as this sounds, this is the most complicated Arduino program I've written. Thanks in advance, I can't figure it out.