How to make something loop

.

Moderator edit, and timeout for vandalism

It looks like your program turns the LED off immediately if the "maximum" button is not pressed. Is that what's meant to happen?

IMHO even though your program is short if you break it up into functions with meaningful names it will be much easier to develop and debug. Have a look at Planning and Implementing a Program

...R

Correct, it turns off the LEDs immediately after the maximum is not pressed. I want it to always turn on the LEDs 100 milliseconds after the maximum is pressed and not just the first time.

This is your 4th post of this under different subjects and yet the only changes that appear to have been made are the ones I gave you a week ago. What gives?

Yea because it was all good until I noticed that it doesn't loop the millis statement even though it is in the void loop of the sketch.

By continually re-posting you deprive others of the audit trail that led to the current state of development. This is unfair to those who may choose to help as you may be wasting their time by forcing them to re-visit issues which have already been discussed. Our time may mean nothing to you, but to most of us it is important. We would not like to think that we are being drawn along redundant paths.

I have reported this to the moderator. Perhaps the threads will be consolidated at which time those who choose to continue with your assistance can resume with a complete picture.

DKWatson, have I asked you specifically to help me? I post my questions in the forum so that I can learn my mistakes and others can learn as well. You would not believe how much I have learned from reading through forums and topics on the community page. Their are so many topics that you can look through and if you don't like my topics I'd just look at other topics rather than report someone that have not asked you for anything to moderator. Is it wrong to post 4 topics on the forum? Have I done anything that would waste people's time? You are being very unfair.

DKWatson:
By continually re-posting you deprive others of the audit trail that led to the current state of development.

Can you even explain what you meant by "re-posting"? Am I reposting the same topics? In case you didn't notice, all my topics link to the same project but have nothing to do with each other. Every topic I posted was a completely different question that I had.

I have worked alongside some of these people for years, not just days. One thing that you will come to learn is that in spite of the apparent jousting, we support each other. We are here and trying to help those like yourself because we choose to be. Nobody is paying us or forcing us. How you choose to receive the advice offered will, to a large extent, determine the level of assistance given. Nobody wishes to be trivialized and by restarting threads as new posts does just that. Editing posts is a similar form of poor etiquette. So, in direct response to your latest post:

Is it wrong to post 4 topics on the forum? No, but you have not posted 4 topics, you have posted the same topic 4 times under different headings.

Have I done anything that would waste people's time? Perhaps, by not exposing the history of progress.

You are being very unfair. Maybe, but this is a technical forum, not some self-help, feel-good love-in.

Remember, perception is reality. In the end, it doesn't much matter what you think, it's what others think.

DKWatson, posting 4 same topics under different headings is not what I did. Yes, my topics share some similarities, but are completely different in the question. Everyone has the right to ask and answer questions and I have gotten assistance that have helped me and should also help others in my previous topics and I am still trying to figure out how to get my project working right as I really need to finish my work asap. I have always done what I was advised to do in my previous topics and have certainly thanked people that took the liberty to help me, including you. I have always mentioned that I am a beginner to Arduino programming as I want people to know that this whole thing is new to me and I am still in a learning process. DKWatson I am just trying to move on with my project so that we all can benefit; no one is being forced or specifically asked to help, that's the beauty of this community which is that it's open for anyone. I am still looking for solutions and after researching continuously I still can't figure out what I have wrong in my code so if anybody would offer to help I'd really appreciate that.

In the real world, every experience, good or bad, is an opportunity to learn. It is widely accepted that we learn more from our failures than our successes. Generally, when we start a project we open a file for it, assign it a name, number, whatever. That file stays with the project for its life-cycle, functioning as a repository for everything and anything relevant. It also functions as a reference to those working on the same project so they might see what others are doing or have done. There are reasons why things are done this way.

By starting 4 different threads on the same project, regardless of how you choose to defend the semantics, you are effectively closing out the history-to-date of all the other work that went in to getting you to where you are. As I have already mentioned, this deprives others of the mistakes/successes already made and in some cases may cause good minded people to unknowingly repeat effort because the project's documentation is not available to them. Do not perceive this as an attack on you or your project. If you come away from this with more than just a working knowledge of how to script a bit of code, then the effort has been worthwhile. Whether you choose to learn or not is up to you, nobody can force you.

You dilute the issue by starting from scratch with a new post under a different heading. If you are overtly trying to compartmentalize, you need to be a bit more creative, otherwise keep people in the loop.

DKWatson, there is no reason for you to carry on this conversation like that as you are wasting people’s time reading though your replies that are completely off-topic. It’s up to you to keep on responding like that and wasting your time, my time, and everyone’s time. I’m not even gonna bother responding to you anymore if you keep on going off-topic; I am trying to figure out solutions to my project and who ever chooses to support will be appreciated.

And DKWatson please, with all respect, end this as I really wouldn’t like anyone to feel bothered by me; so if you think that I was wrong then I apologize. I really appreciate all the help that you gave me in the past, but I gotta move on with my work and finish before time runs out.

Can someone inform me what I have wrong in my code as I want pin 4 to turn on the LEDs 100 milliseconds after it (pin 4) gets HIGH every time and not only the first time?

Here’s my code so far:

int brightness = 200;

//const byte LED       = 11;
//const byte maximum   = 10;
//const byte decrement = 8;
//const byte increment = 9;

const byte LED       = 3;
const byte maximum   = 4;
const byte decrement = 7;
const byte increment = 8;

void setup()
{
  pinMode(LED, OUTPUT);             // Set pin 3 to be in output mode
  pinMode(decrement, INPUT_PULLUP); // Set pin 7 to be in input mode
  pinMode(increment, INPUT_PULLUP); // Set pin 8 to be in input mode
}

void loop()
{
  if (digitalRead(decrement) == LOW)
  {
    brightness--;                  // If button on pin 7 is pressed, reduce brightness
  }

  if (brightness < 10)
  {
    brightness = 10;                // Don't let brightness drop below zero
  }

  if (digitalRead(increment) == LOW)
  {
    brightness++;                  // If button on pin 8 is pressed, increase brightness
  }

  if (brightness > 255)
  {
    brightness = 255;              // Don't let brightness get above 255
  }
  delay(5);                      // Wait a short time, just to slow things down a little

  static byte high_flag = 0;
  static unsigned long high_start_time;
  if (digitalRead(maximum) == HIGH)       //if pin 4 is HIGH
  {
    if (high_flag)
    {
      if ((millis() - high_start_time) >= 100)
      {
        analogWrite(LED, brightness); // Set pin 3 to the new brightness level

      }
    }
    else
    {
      high_start_time = millis();
      high_flag = 1;
    }
  }
  else
  {
    analogWrite(LED, 0);          //else turn it off
  }
 }
[code]

It seems to me @DKWatson is giving good advice that is being continuously rejected. I am amazed that he has tried so hard to help someone who seems to prefer a grievance to a solution.

...R

I never rejected DKWatson's advice.

ZiadHamwi:
I never rejected DKWatson's advice.

So what was the purpose of Replies 4, 6, 7, 9 and 11 ?

They were certainly not in the style "Thank you for trying to help me"

...R

The forum will be enjoying a brief timeout from @ZiadHamwi