Hello. im trying to make a steppermotor run when I press a button and until the value from a photoresistor exceeds 300.
the problem is that it takes half a second from when the value is higher than 300 until the motor stops.
Here is the code:
void loop()
{
digitalWrite(led, HIGH); // Turn the LED on
int c = analogRead(A0);
Serial.println(c);
buttonState = digitalRead(buttonPin);
if ((buttonState == HIGH) && (c < 300)) {
Serial.println("Press");
while (c < 300) {
c = analogRead(A0);
Serial.println("Run");
myStepper.step(stepsPerRevolution);
Thanks in advance!