Issue with blink no delay

hello I understand out to blink without delay but i was wondering how do you make an led blink multiple
EX on off reel 3 time then 2 long on/off then 1 long on without using delay.
I would like to put a 4 ch rf remote so i can put it on and off without having the problem of the delay hoging up everything.

What is reel?

Anyway, if you have to ask this question then maybe you do not understand Blink Without Delay.

You need to keep track of where you are in the sequence by using a variable, and use millis() to keep track of the time.

Experts use an enum to keep track of where they are in the sequence, but you can get by with an int or byte variable.

Sorry very late let me try this again.I do understand how it work.I am trying to make a buzzer do this.
beep 3 time very quickly then 2 longer beep and 1 long beep in a loop.I can do this with delay no problem but when i click any button on my remote it will have to be perfectly timed to get out of the loop.With a debounce and not using delay the TX is not always in use and then the button work everytime i press it.Is it better to keep it with delay and just figure a way out of the loop or use no delay.Sorry.

You're led can be in one of three modes (or states)
1)
flashing fast 3 times
2)
flashing slow 2 times
3)
on

You can keep a variable that indicates which part of the code needs to be executed. Once a mode is completed, you update the variable to reflect the next mode and the next time loop() is entered the code for the new mode is executed.

The first two modes will execute code based on blink-without-delay; they will have to keep a counter to indicated how many times the led has flashed. If counter reaches 3 (or 2), go to next mode.

oh ok i understand way more complicated then i though it would be!But seem to be a very good way to keep the TX from worker all the time!

Thank you very much guys!I was able to fix it with your help.My code look like crap but it work without any issue!

Flyinghost:
Thank you very much guys!I was able to fix it with your help.My code look like crap but it work without any issue!

Aren’t you going to show it to us?

The demo Several Things at a Time is an extended example of BWoD and may help with understanding.

Also see Planning and Implementing a Program

...R

Flyinghost:
Thank you very much guys!I was able to fix it with your help.My code look like crap but it work without any issue!

To read up on: finite state machine

Because you probably just made your first.

ok i will read on that.Here the code there is 2 part copied from the example since I am a noob at this but the fact that this is actually working making me feel proud for some reason lol so don’t hate on the noob.

int RemoteA = 2;
int RemoteB = 3;
int RemoteC = 4;
int RemoteD = 5;
int Buzzer = 11;

int menuCounter = 0;
int counter = 0;

int customInterval = 0;

int ledState = HIGH;         // the current state of the output pin
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
int ledState2 = LOW;

long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers
const long interval = 500;
unsigned long previousMillis = 0;

void setup() {

  pinMode(RemoteA, INPUT);
  pinMode(RemoteB, INPUT);
  pinMode(RemoteC, INPUT);
  pinMode(RemoteD, INPUT);
  pinMode(Buzzer, OUTPUT);
  Serial.begin(9600);

  // set initial LED state
  //digitalWrite(Buzzer, ledState);
}

void loop()
{
  unsigned long currentMillis = millis();
  int reading = digitalRead(RemoteA);

  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay)
  {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState)
    {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH)
      {
        ledState = !ledState;
        menuCounter = menuCounter + 1;
      }

    }
  }
  if (menuCounter == 1)
  {
    if (currentMillis - previousMillis >= interval)
    {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState2 == LOW)
      {
        ledState2 = HIGH;
      } else {
        ledState2 = LOW;
      }
      counter = counter + 1;
      // set the LED with the ledState of the variable:

    }
    digitalWrite(Buzzer, ledState2);
  }
  // set the LED:
  if (counter > 20 && counter < 41 )

  {
    customInterval = interval - 250;
    if (currentMillis - previousMillis >= customInterval)
    {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState2 == LOW)
      {
        ledState2 = HIGH;
      } else {
        ledState2 = LOW;
      }
      counter = counter + 1;
      // set the LED with the ledState of the variable:

    }
    digitalWrite(Buzzer, ledState2);
  }
  if (counter > 41 && counter < 61)
   {
    customInterval = interval - 400;
    if (currentMillis - previousMillis >= customInterval)
    {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState2 == LOW)
      {
        ledState2 = HIGH;
      } else {
        ledState2 = LOW;
      }
      counter = counter + 1;
      // set the LED with the ledState of the variable:

    }
    digitalWrite(Buzzer, ledState2);
  }

  if (counter > 61 && counter < 81)
  {
    digitalWrite(Buzzer, HIGH);
  }

  if (counter > 81)
  {
    counter = 0;
  }
  if (menuCounter  == 2)
  {
    menuCounter = 0;
    counter = 0;
    digitalWrite(Buzzer, LOW);
  }

  lastButtonState = reading;
  
}

What happens when counter is 41, 61 or 81?
Your logic covers < and > for each but no ==, <= or >= of any.

if ( value < 10 )
{
// code
}

if ( value > 10 )
{
// code
}

Does not cover value of 10, maybe it should not either.

your right lol man i'm sad at coding lol.Well it a range so as long it switch to the next line of code after it pass 21 ,41 ,61 ,81 and reset and the loop continue I'm ok with this lol

We were all beginners once. We crawled before we learned to walk and we cut our teeth on examples and our own noob code.

Perhaps you missed me doing that almost 40 years ago. :slight_smile:

Haha!well said thank you for the support now my drone founder module work hahaha!