Blink not using delay

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

Hi @donmerrick. I'm going to ask you to post some additional information that might help us to identify the problem.

Please do this:

  1. When you encounter an error, you'll see a button on the right side of the orange bar in the Arduino IDE: Copy error messages (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button.
  2. Open a forum reply here by clicking the Reply button.
  3. Click the </> icon on the post composer toolbar. This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  4. Press Ctrl+V. This will paste the compilation output into the code block.
  5. Move the cursor outside of the code block markup before you add any additional text to your reply.
  6. Click the Reply button to post the output.
1 Like

Here's a version that compiles at least:

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,50); //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();
}
1 Like
    Flasher led1(1, 3500,); //pin#, long on, long off (MAIN FAN relay ON 30SEC / OFF 30MINS

Missing parameter

1 Like

I am sorry, Is this correct?

Arduino: 1.8.15 (Windows 10), Board: "Arduino Uno"





















myledrelayflash2:49:14: error: expected identifier before numeric constant

 Flasher led1(1,3500,); //pin#, long on, long off (MAIN FAN relay ON 30SEC / OFF 30MINS

              ^

myledrelayflash2:49:14: error: expected ',' or '...' before numeric constant

myledrelayflash2:50:14: error: expected identifier before numeric constant

 Flasher led2(2, 5000, 4500);        //second fan relay on 10sec/ off for 1min

              ^

myledrelayflash2:50:14: error: expected ',' or '...' before numeric constant

myledrelayflash2:51:14: error: expected identifier before numeric constant

 Flasher led3(3, 1e+4, 900); //pin#, long on, long off (MAIN FAN relay ON 1SEC / OFF 10secs

              ^

myledrelayflash2:51:14: error: expected ',' or '...' before numeric constant

myledrelayflash2:52:14: error: expected identifier before numeric constant

 Flasher led4(4, 500, 500);        //second fan relay on 1/2 sec/ off for 1/2 sec

              ^

myledrelayflash2:52:14: error: expected ',' or '...' before numeric constant

myledrelayflash2:53:14: error: expected identifier before numeric constant

 Flasher led5(5, 2000, 3000);

              ^

myledrelayflash2:53:14: error: expected ',' or '...' before numeric constant

myledrelayflash2:54:14: error: expected identifier before numeric constant

 Flasher led6(6, 1500, 1500);

              ^

myledrelayflash2:54:14: error: expected ',' or '...' before numeric constant

myledrelayflash2:56:14: error: expected identifier before numeric constant

 Flasher led7(7, 1e+4, 900); //pin#, long on, long off (MAIN FAN relay ON 1SEC / OFF 10secs

              ^

myledrelayflash2:56:14: error: expected ',' or '...' before numeric constant

myledrelayflash2:57:14: error: expected identifier before numeric constant

 Flasher led8(8, 500, 500);

              ^

myledrelayflash2:57:14: error: expected ',' or '...' before numeric constant

myledrelayflash2:58:14: error: expected identifier before numeric constant

 Flasher led9(9, 2000, 3000);

              ^

myledrelayflash2:58:14: error: expected ',' or '...' before numeric constant

myledrelayflash2:59:15: error: expected identifier before numeric constant

 Flasher led10(10, 1500, 1500);

               ^~

myledrelayflash2:59:15: error: expected ',' or '...' before numeric constant

myledrelayflash2:60:15: error: expected identifier before numeric constant

 Flasher led11(11, 500, 500);

               ^~

myledrelayflash2:60:15: error: expected ',' or '...' before numeric constant

myledrelayflash2:61:15: error: expected identifier before numeric constant

 Flasher led12(12, 2000, 3000);

               ^~

myledrelayflash2:61:15: error: expected ',' or '...' before numeric constant

myledrelayflash2:63:12: error: expected ';' at end of member declaration

 void setup()

            ^

myledrelayflash2:83:1: error: expected '}' at end of input

 }

 ^

C:\Users\Don\Documents\Arduino\myledrelayflash2\myledrelayflash2.ino\myledrelayflash2\myledrelayflash2.ino: In member function 'void Flasher::loop()':

myledrelayflash2:69:3: error: invalid use of member function 'Flasher Flasher::led1(int)' (did you forget the '()' ?)

   led1.Update();

   ^~~~

myledrelayflash2:69:3: error: invalid use of member function 'Flasher Flasher::led1(int)' (did you forget the '()' ?)

myledrelayflash2:70:3: error: invalid use of member function 'Flasher Flasher::led2(int)' (did you forget the '()' ?)

   led2.Update();

   ^~~~

myledrelayflash2:70:3: error: invalid use of member function 'Flasher Flasher::led2(int)' (did you forget the '()' ?)

myledrelayflash2:71:3: error: invalid use of member function 'Flasher Flasher::led3(int)' (did you forget the '()' ?)

   led3.Update();

   ^~~~

myledrelayflash2:71:3: error: invalid use of member function 'Flasher Flasher::led3(int)' (did you forget the '()' ?)

myledrelayflash2:72:3: error: invalid use of member function 'Flasher Flasher::led4(int)' (did you forget the '()' ?)

   led4.Update();

   ^~~~

myledrelayflash2:72:3: error: invalid use of member function 'Flasher Flasher::led4(int)' (did you forget the '()' ?)

myledrelayflash2:73:3: error: invalid use of member function 'Flasher Flasher::led5(int)' (did you forget the '()' ?)

   led5.Update();

   ^~~~

myledrelayflash2:73:3: error: invalid use of member function 'Flasher Flasher::led5(int)' (did you forget the '()' ?)

myledrelayflash2:74:3: error: invalid use of member function 'Flasher Flasher::led6(int)' (did you forget the '()' ?)

   led6.Update();

   ^~~~

myledrelayflash2:74:3: error: invalid use of member function 'Flasher Flasher::led6(int)' (did you forget the '()' ?)

myledrelayflash2:76:3: error: invalid use of member function 'Flasher Flasher::led7(int)' (did you forget the '()' ?)

   led7.Update();

   ^~~~

myledrelayflash2:76:3: error: invalid use of member function 'Flasher Flasher::led7(int)' (did you forget the '()' ?)

myledrelayflash2:77:3: error: invalid use of member function 'Flasher Flasher::led8(int)' (did you forget the '()' ?)

   led8.Update();

   ^~~~

myledrelayflash2:77:3: error: invalid use of member function 'Flasher Flasher::led8(int)' (did you forget the '()' ?)

myledrelayflash2:78:3: error: invalid use of member function 'Flasher Flasher::led9(int)' (did you forget the '()' ?)

   led9.Update();

   ^~~~

myledrelayflash2:78:3: error: invalid use of member function 'Flasher Flasher::led9(int)' (did you forget the '()' ?)

myledrelayflash2:79:3: error: invalid use of member function 'Flasher Flasher::led10(int)' (did you forget the '()' ?)

   led10.Update();

   ^~~~~

myledrelayflash2:79:3: error: invalid use of member function 'Flasher Flasher::led10(int)' (did you forget the '()' ?)

myledrelayflash2:80:3: error: invalid use of member function 'Flasher Flasher::led11(int)' (did you forget the '()' ?)

   led11.Update();

   ^~~~~

myledrelayflash2:80:3: error: invalid use of member function 'Flasher Flasher::led11(int)' (did you forget the '()' ?)

myledrelayflash2:81:3: error: invalid use of member function 'Flasher Flasher::led12(int)' (did you forget the '()' ?)

   led12.Update();

   ^~~~~

myledrelayflash2:81:3: error: invalid use of member function 'Flasher Flasher::led12(int)' (did you forget the '()' ?)

myledrelayflash2:82:3: error: 'led13' was not declared in this scope

   led13.Update();

   ^~~~~

C:\Users\Don\Documents\Arduino\myledrelayflash2\myledrelayflash2.ino\myledrelayflash2\myledrelayflash2.ino:82:3: note: suggested alternative: 'led1'

   led13.Update();

   ^~~~~

   led1

C:\Users\Don\Documents\Arduino\myledrelayflash2\myledrelayflash2.ino\myledrelayflash2\myledrelayflash2.ino: At global scope:

myledrelayflash2:83:1: error: expected unqualified-id at end of input

 }

 ^

exit status 1

expected identifier before numeric constant



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Hello,
nice error report.
And now?

No need to apologize. It looks like some of the other forum members have already provided a solution for the error without needing the full error output. So please check their replies for the fix.

The change Wildbill made has certainly made it compile, Thank you Wildbill.
Also thank you to you all for your very fast help.
Since my dementia has started, I have forgotten a lot of stuff as I used to be a surfacemount electronics tech and hobbied a lot with electronics and started to learn Arduino during the early stages but, sometimes I just look at my designs and think, what the hell does that do! Horrible.
I thank you all.

I'm not so sure that indicates a major memory problem in itself. :grin: Easy enough to forget.

Good luck with your projects and your health problems.
Too many good people affected.
I agree with @Paul_B , I do it all the time.
I can lose anything in less than one minute, and yes, I too wonder what I did something for.
I can't cure the first, but I can cure the second with lots of comments and lots of index cards with additional notes.

I will offer that you add the name of the file in startup
then Serial.print("filename");
in a year, you can connect it, turn on the serial monitor and see what it was called.

also, at the very beginning of the sketch put in comments

/* this version was fixed by wildbill on the Arduino Forum

I posted the actual URL, but the forum turned it into a link.
the idea is to be able to go to where you got information.

ps: when I pull a sketch from the web, I also post a link to where I got that.
too many times I could not figure something out.

1 Like