Hello everyone,
I tried to make a LED blinking and at the same time a Stepper motor turning. I got both in one loop, but the program goes in the loop only 1 time. So it blinks once and then the motor turns one.
Can you help plz with a solution.
This is my code... and thanks in advance
#include <Stepper.h>
Stepper Motor(1024,2,3,4,5);
int Lightsensor = A0; // Analogen Eingang 0 als Analog0 definieren
int Brightness = 0; // Variabel helligkeit auf 0 setzen
int Limit = 10; // Grenzwert hell-dunkel
void setup()
{
Serial.begin(300); //Serial-Übertragung auf 300Baud-reicht völlig
pinMode(10, OUTPUT); //Digitaler-Ausgang 10 für LED-Ansteuerung
Motor.setSpeed(10);
}
void loop()
{
Brightness = analogRead(Lightsensor);
if (Brightness < Limit)
{
digitalWrite(10, HIGH);
delay(50);
digitalWrite(10,LOW);
delay(50);
Motor.step(100);
delay(100);
Motor.step(50);
delay(100);
Motor.step(100);
}
else
{
digitalWrite(10, LOW);
}
}