Hi all, I hope you are all safe!
I found some code on the internet a few years ago. I changed it to turn on lots of led's which were going to be lights in a small fairy garden I was making for my wife. Sadly, due to illness, I stopped using the arduino and forgot many things.
I really would like to finsih this project but, when I tested it an error came up. I am not sure if this is a glitch, misstype on my part or ??, either way it fails to compile. I want to ask for help with this, I am in no mental condition or age to learn programming again so please do not lecture me, I simply want this code running as it once did.
The error is : "expected identifier before numeric constant" ??
I thank you for any help you can give to me.
****class Flasher
{
// Class Member Variables
// These are initialized at startup
int ledPin; // the number of the LED pin
long OnTime; // milliseconds of on-time
long OffTime; // milliseconds of off-time
// These maintain the current state
int ledState; // ledState used to set the LED
unsigned long previousMillis; // will store last time LED was updated
// Constructor - creates a Flasher
// and initializes the member variables and state
public:
Flasher(int pin, long on, long off)
{
ledPin = pin;
pinMode(ledPin, OUTPUT);
OnTime = on;
OffTime = off;
ledState = LOW;
previousMillis = 0;
}
void Update()
{
// check to see if it's time to change the state of the LED
unsigned long currentMillis = millis();
if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
{
ledState = LOW; // Turn it off
previousMillis = currentMillis; // Remember the time
digitalWrite(ledPin, ledState); // Update the actual LED
}
else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
{
ledState = HIGH; // turn it on
previousMillis = currentMillis; // Remember the time
digitalWrite(ledPin, ledState); // Update the actual LED
}
}
Flasher led1(1,3500,); //pin#, long on, long off (MAIN FAN relay ON 30SEC / OFF 30MINS
Flasher led2(2, 5000, 4500); //second fan relay on 10sec/ off for 1min
Flasher led3(3, 1e+4, 900); //pin#, long on, long off (MAIN FAN relay ON 1SEC / OFF 10secs
Flasher led4(4, 500, 500); //second fan relay on 1/2 sec/ off for 1/2 sec
Flasher led5(5, 2000, 3000);
Flasher led6(6, 1500, 1500);
Flasher led7(7, 1e+4, 900); //pin#, long on, long off (MAIN FAN relay ON 1SEC / OFF 10secs
Flasher led8(8, 500, 500);
Flasher led9(9, 2000, 3000);
Flasher led10(10, 1500, 1500);
Flasher led11(11, 500, 500);
Flasher led12(12, 2000, 3000);
// Flasher led13(13, 100, 100);
void setup()
void loop()
{
led1.Update();
led2.Update();
led3.Update();
led4.Update();
led5.Update();
led6.Update();
led7.Update();
led8.Update();
led9.Update();
led10.Update();
led11.Update();
led12.Update();
led13.Update();
}
Thank you