Hi all,
I am new to Arduino and am working on an architectural project where a sun shading device opens up when it is sunny out and then closes when it is shady or night. Also, am trying to incorporate a proximity sensor to try and have it slightly interact with people who are walking underneath by closing the canopy slightly. The design is basically a upside-down umbrella controlled by strings and the stepper motor pulls those strings (to close it) or releases the strings (to open it). I have been able to get the stepper motor and photoresistor to work however the motors will continue to try and rotate since it is in a loop. I have tried putting everything in Void Setup and leaving Void Loop blank but I keep getting errors that Void loop is blank. I have attached my code and images if that helps!
Thank you so much,
-Sam Sawyer-Standley
// Arduino stepper motor control code
#include <Stepper.h>
// Include the header file
// change this to the number of steps on your motor
#define STEPS 32
// create an instance of the stepper class using the steps and pins
Stepper stepper(STEPS, 8, 10, 9, 11);
int val = 0;
int LED = 7;
int LDR = A0;
void setup()
{
Serial.begin(9600);
stepper.setSpeed(800);
pinMode(LED, OUTPUT);
pinMode(LDR, INPUT);
}
void loop()
{
int LDRValue = analogRead(LDR);
Serial.print("sensor = ");
if (LDRValue <=100)
{
digitalWrite(LED, HIGH);
val = Serial.parseInt();
stepper.step(800);
Serial.println(val);
//for debugging
}
if (LDRValue >=100)
{
digitalWrite(LED, LOW);
val = Serial.parseInt();
stepper.step(-800);
Serial.println(val);
//for debugging
}
}

6 posts - 4 participants