Hi,
A simple project to finish. The project is simple, but I'm a complete beginner. It's about motorised blinds which automatically close when it is bright and open when it is dark. Thanks for any help
this is the code :
''''
#include <Stepper.h>//Include the Arduino Stepper Library
const float STEPS_PER_REV = 32; // Number of steps per internal motor revolution
const float GEAR_RED = 64;// Amount of Gear Reduction
const float STEPS_PER_OUT_REV = STEPS_PER_REV * GEAR_RED;// Number of steps per geared output rotation
int StepsRequired;// Number of Steps Required
Stepper steppermotor(STEPS_PER_REV, 8, 10, 9, 11);
int photo; // sensor
void setup()
{
// Nothing (Stepper Library sets pins as outputs for stepper motor)
pinMode(6,OUTPUT); // led blue
pinMode(5,OUTPUT); // led green
}
void loop()
{
photo = analogRead(A1);
Serial.begin(9600);
Serial.print("signal from sensor = " );
Serial.println(photo);
if (photo <250){
digitalWrite(6,HIGH); // blue led is on
digitalWrite(5,LOW);
StepsRequired = STEPS_PER_OUT_REV * 2 ; // Rotate CW 2 turns
steppermotor.setSpeed(1000);
steppermotor.step(StepsRequired);
delay(1000);}
else {
photo = analogRead(A1);
Serial.begin(9600);
Serial.print("signal from sensor = " );
Serial.println(photo);
digitalWrite(6,LOW);
digitalWrite(5,HIGH);//green is on
StepsRequired = - STEPS_PER_OUT_REV * 2; // Rotate CCW 2 turns
steppermotor.setSpeed(1000);
steppermotor.step(StepsRequired);
delay(1000);
}
}
'''