Author Options:

Rain sensor + stepper motor + arduino (Need help) Answered

I am working on a SMART WIndow.
This window is supposed to close automatically when it rains.
Suppose the sliding window is being closed using a motor.
How can i write a program to serve the purpose:
When the rain sensor sense rain > activate the motor to close the window > after window fully closed > deactivate the motor.
When the rain sensor dries (rain stop) > activate the motor to open the window > after window fully open > deactivate the motor.


Can any one tell me how to write a code for a Stepper motor to stop after reaching the limit switch?

This is for a sliding window. The Stepper motor will rotate and close or open the window. 2 limit switches are placed on both ends. So when the limit switch is activated, the Stepper motor stops operating.

You should be moving the motor in little steps or increments. It needs to check whether either switch has be triggered before it makes its next move. Or if you have been keeping track of its position, then the endstops are a safety mechanism to keep it from going too far.

Basic I/O operations, start in the Arduino Playground with one of the many example available and match it for the sensors you use.

take the task in components. meaning first work on the rain gauge logic. perhaps a resberry pi with Sensehat so you can make it a weather station and can better predict the weather (barometric pressure). With the Rasberry Pi you could write a script to perform the weather logic you are wanting. The window simply needs to be told when to open (+) volts or close (0) volts from controller. The mechanics of the window I would imagine would have a top and bottom sensor to trigger when to disengage the motor (similar to a garage door opener). The other option is use pneumatic devices to open / close the window so with no pressure the window closes (spring or weight driven) and with pressure it opens up.. good luck