Hi there
I'm trying to teach myself the use of the state machine. I've been following a useful video on youtube. Seems like a key subject
I've tried to replicate his code at the end of the video with a some tweaks - the names of the LED's. But I'm running into trouble with an error code:
exit status 1
expected unqualified-id before numeric constant
Here's the code:
// constants
const int 12ledPin = 12; // the number of the LED pin
const int 13ledPin = 13;
const long 12interval = 2000; // interval at which to blink (milliseconds)
const long 13interval = 4000;
// Variables
int 12ledState = LOW; // ledState used to set the LED
int 13ledState = LOW;
unsigned long previous12Millis = 0;
unsigned long previous13Millis = 0;
void setup() {
// set the digital pin as output:
pinMode(12ledPin, OUTPUT);
pinMode(13ledPin, OUTPUT);
currentMillis = millis();
}
void loop() {
currentMillis = millis();
manage12led();
manage13led();
}
void manage12led() {
if (currentMillis - previous12Millis > 12interval) {
previous12Millis = currentMillis;
13ledState = (12ledState == HIGH) ? LOW : HIGH;
digitalWrite(12ledPin, 12ledState);
}
}
void manage13led() {
if (currentMillis - previous13Millis > 13interval) { // compares current time with previous, references interval. If interval is reached then ....
previous13Millis = currentMillis; // records time
13ledState = (13ledState == HIGH) ? LOW : HIGH; // If state = HIGH, change to LOW. If not change to HIGH
digitalWrite(13ledPin, 13ledState); // tell 13LedPin to be the new state
}
}
Hope you can help