Hello All!
I am currently completing a school project where I am using a stepper motor to move a curtain up and down based on a light sensor. I am using a stepper because I already had the motors handy. This project is basically a basic mechatronics program where we need to utilize a microcontroller, a sensor, and an actuator. The high level basis of the project is to simulate an automatic window curtain.
I am using an Arduino Uno with a stepper motor shield provided by adafruit (Arduino v2 Kit - v2.3). I used the example code provided by adafruit to get the stepper to spin in a loop.
My goal is to use a photocell provided with the complete arduino kit to control whether the stepper will move up or down. Below is a sequence of what I am trying to accomplish.
Sequence:
Power on
Check if sensor is on or off
If off then
rotate counter clockwise for a set timer
stop
If on then
rotate clockwise for a set timer
stop
I also would like the above to only start spinning if the sensor changes, I don't want a loop to check if the sensor is on/off because (in my mind) that means the stepper would constantly be spinning.
I am completely new to coding in general (I am a mechanical engineering student) so trying to figure out how to piece all of the information together has been difficult to say the least.
Any advice, any demonstrations, code examples, explanations, written code would be very helpful.
If providing code, please explain the pieces of it so I can logically wrap my head around the concept in order to utilize it.
Thank you for reading!