Control by time cycles

MorganS:

  1. Please edit your post to add [ code ] tags. The forum software eats some of your code if you don't.

  2. You gave this pin a name. Use the name.

  3. This does nothing. Why do you have so many nothings in your code?

  4. You are going to have to define the sequence a little more precisely. Do you want it to start when the button is first touched or when the button is released?

*starts when the button is first touched...

first led turns on.... pased 2 seconsd turn the led off ..after that the stepper motor start at steps and speed and finally when the stepper motor finish turn on other led by 4 seconds....

y only try to turn on the led and after the stepper but it doesn't work as i wrote it...

What happens if the button is pushed again during the cycle? Is there going to be a STOP button?

Hello,

i don't know if you can help me,

i want to control with one push button:

one led with time(2seconds) then when this turn off the stepper moves then when the stepper stops other led turn on with time(4 seconds) and finish....

I´m start with this but something is missing because led is turn on all the time

const int buttonPin2 = 24;
const int ledPin2 = 7;

int buttonState2 = 0;

#include <Stepper.h>
const int stepsPerRevolution = 800;
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup()

{

pinMode(7, OUTPUT);
pinMode(buttonPin2, INPUT);
myStepper.setSpeed(120);
Serial.begin(9600);

}

void loop()
{

buttonState2 = digitalRead(buttonPin2);
if (buttonState2 == HIGH) {
digitalWrite(ledPin2, HIGH);
delay(0);}

else
{digitalWrite(ledPin2, LOW);
delay(2000);}
if (buttonState2==LOW){
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(0);}