Go Down

Topic: cycling 4 LEDs at varrying speeds (Read 6 times) previous topic - next topic


Yes I can see how I can manually change the interval But I want to do it automatically.


Oct 08, 2012, 09:59 pm Last Edit: Oct 08, 2012, 10:18 pm by AWOL Reason: 1
Have your program do it for you. That's about as close to automatic as you're going to get.
Code: [Select]
unsigned long currentMillis = millis();

  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 (ledState == LOW)
      ledState = HIGH;
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);

Breaks down to:
Look at the time
Is it time to do something?
If so, do something

Where "do something" can include change the amount of time until I next have to do something.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


But I want to do it automatically.

You have our permission. If you need help with that, you must define when/under what conditions to change the value, and how much to change it by.


I had to walk away from it right now I'm not at home so I will take a look at it when I get home thanks


The Arduino community isn't here to help you get your project done; we're here to help you understand how to build your project.

If you want to work under the get the project done now, I'll figure out how it actually works later model, then there is a Gigs and Collabaration section where you can get people to write code for you.

You say you understand things better when you can take something, modify it and see what happens. You're welcome to do that with any of the examples and I would encourage you to spend a lot of time doing that with the Blink without Delay example because it is such an important fundamental concept. If you're not willing/interested in putting the time into understanding how it works and figuring out how you can take it and apply it to your own projects, then the aforementioned section would be a better place to get help (at a price) in the form of working code to your specifications.

Go Up