Need some coding help

This is sequencing the actions.

I suggest you set an integer variable, let's call it STEP, and set it's value initially to 0
When you press the start button have the program increment it to a 1 (stage 1)
Then have the first part of the program test for 'if STEP = 1 then (your first actions)
At the end of step 1 actions have the program increment STEP to value 2.
Clearly it will now ignore the STEP = 1 section of the code, and move on to the code which satisfies 'if STEP = 2'.

...and so on

At the end of the last step (you decide how many) make STEP = 0 again, and the program will wait for the pushbutton to be pressed before starting again.

As for the potentiometer modification, I'm sure better minds than mine will be along soon.

I can't help with the specific code as I'm a novice too!

GM

Alexpaine:
I have no problem getting it to start with a push button and to do the duty cycle, what I can't figure out is how to get the duty cycle to run for the five seconds, then switch to the next duty cycle and then stop

You need to post your program so we can see what you have been trying.

The concept proposed by @Glorymill should help

Also have a look at how millis() is used to manage timing in Several Things at a Time.

And see Using millis() for timing. A beginners guide if you need more explanation.

...R

here is what I have got so far..

#define LED 9
#define KNOB 0
const int buttonPin1 = 2; // the number of the pushbutton pin
const int buttonPin2 = 4; // second pushbutton
const int ledPin = 9; // for testing purpose will switch to relay later
int buttonState = 0;

void setup() {
pinMode(LED, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);

}

void loop() {
buttonState = digitalRead(buttonPin1);
if (buttonState == HIGH) {
analogWrite(9, 64);
//need 5 sec run time
analogWrite(9, 127);
//need 5 sec run time
analogWrite(9, 215);
// need 5 sec run time
for(;;){} // i think this will prevent the loop from restarting?????
}

buttonState = digitalRead(buttonPin2);
if (buttonState == HIGH) {

// Read the value of the potentiometer knob
int knobValue = analogRead(KNOB);

// Map the potentiometer value to 1-255
int intensity = map(knobValue, 1, 1024, 1, 255);

// Output the respective value to the LED
analogWrite(LED, intensity);
}
}

You should not be trying to stop loop() from repeating - quite the opposite, you want it to repeat as often as possible.

You can have a variable that gets tested to determine whether an action should happen. Something like

void loop() {
   if (jobDone == false) {
      doJob();
   }
}

void doJob() {
  // your code to do something
  jobDone = true; // so it won't happen again
}

...R

PS ... It's all the fault of the little yellow guys with the grin.

When posting code please use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor See How to use the Forum

Also please use the AutoFormat tool to indent your code for easier reading.

What i would like it to do is "flash" the led for 5 Seconds at a certain flash rate pause flash LED for 5 seconds at a different pulse rate pause Flash the LED for 5 seconds at a different pulse rate and then stop flashing the LED all together and not repeat the loop :confused:

We understood your assignment in outline, the first time you posted.

What have you learned and tried, based on the suggestions already given, and how did that go? (Use code tags to post updated code).

I know i have to use millis () but having a hard time figuring out how to put it into code...

Study this excellent Blink Without Delay tutorial.

Thanks had a quick look over the link you sent
Can I put my head to the grindstone will post something when I got it all done

The code in Several Things at a Time flashes some LEDs and illustrates the use of millis() for timing.

Sorry, I forgot to include the link in Reply #4

Have a look at Using millis() for timing. A beginners guide if you need more explanation.

...R

Im so lost... I have spent the last two hours reading and rereading all about delay millis, I've even tried watching YouTube videos and everything
I understand the concept behind the idea just not how to apply it.

Starting to find this to be way over my head.

It is not a good sign if you had trouble understanding the Bald Engineer's tutorial, linked in reply #8.

No it is not.... You have no idea how frustrating it is.. I am learning very quickly that this is not as easy for me as I had thought..

Alexpaine:
I am learning very quickly that this is not as easy for me as I had thought..

I think sometimes people get stuck because they fail to realize a computer is utterly stupid - which means that a program must describe every little thing at a level of detail which would never be necessary with another human.

...R

Robin2:
I think sometimes people get stuck because they fail to realize a computer is utterly stupid

LOL so true. I recall a question not so long ago which was something like "why doesn't it switch off the LED after I release the button? I only tell it to switch on the LED when the button is pressed, so it should go off when not!"
Answer: "you never told the Arduino to switch off the LED, only to switch it on".

Indeed, you have to spell out everything for a computer, explicitly. They only do what you tell them to do, nothing more and nothing less.

The concept for this assignment is indeed a quite straightforward finite state machine. The trigger for cycling through the states is time (using the millis() timer); every state is doing something specific with your LED.

Robin2:
I think sometimes people get stuck because they fail to realize a computer is utterly stupid - which means that a program must describe every little thing at a level of detail which would never be necessary with another human.

...R

You're very right I do know that computers are stupid and I feel just about as dumb as they are I'm putting my nose to the grindstone and going to see if I can find someone to help me

Wondering if someone out there would be so kind to write the code for me

Such requests would normally go to the "gigs & collaborations" section, and have a price tag attached. Though not likely you'll find someone willing to do your school assignments for you.

wvmarle:
Such requests would normally go to the "gigs & collaborations" section, and have a price tag attached. Though not likely you'll find someone willing to do your school assignments for you.

I kind of wish it was a school project because then I would have a teacher to show me how to do this
I'll put an ad in the gig section to see if I can find somebody thank you for the info.