Hi,
Just started to really toy with an arduino I was bought for christmas, so I’m pretty new to coding on it.
I’m getting the following error when compiling the code below.
“error: expected primary-expression before ‘=’ token”
#define RED 2 // sets the red light to pin 2
#define AMBER 3 // sets the amber light to pin 3
#define GREEN 4 // sets the green light to pin 4
#define ON = 1; // declare what on and off mean
#define OFF = 0;
// Array for the light control
char sequenceLength = 9;
char pinsLights[]={RED, AMBER, RED, AMBER, GREEN, GREEN, AMBER, AMBER, RED};
char stateLights[]={ON, ON, OFF, OFF, ON, OFF, ON, OFF, OFF};
char stateLights[]={10000, 2000, 0, 0, 10000, 0, 3000, 0, 0};
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
// code
void loop()
{
char sequence = 0; // start at element sero of all the arrays
// and do for every light we've programmed
while(sequence<sequenceLength)) // loop for number of sequences
{
// first switch on or off the current light in the sequence
digitalWrite(pinLights[sequence],stateLights[sequence]);
// then if there's a delay then wait (may not need this if delay(0) works correctly)
if(delayLights[sequence])
delay(delayLights[sequence])};
// next light in the sequence
sequence++;
}
}
The error seems to highlight
char stateLights={ON, ON, OFF, OFF, ON, OFF, ON, OFF, OFF};
as being the problem, but for the life of me I don’t see what the issue is. Anyone have any ideas?