I'm working on a little project for daughter, its basically a automatic window for her play house. The window is near completion, everything is complete except the "code"...
Basically I want the window to be controlled by a button, then have the the two reed sensors stop the window while going up or down.
I'm useing a 12v dc worm geared motor(8rpm) with a pulley to have the window go up or down, I followed the schematic's on the link below, to build the circuit so the motor's directions and on/off can be controlled.
What happens if your daughter puts her hand in the path of the window?
Worm drives have produce a huge amount of force, have you put your hand the path of the and tested what happens to you hand,if the window crushes it against the end stop?
Aside from that, the code would be relatively simple, but I'd recommend you write it as a Finite State Machine
To try to prevent any injury Im modifying the window frame with a removable head and side jamb's, so If something does get stuck ill just remove the window from the frame.. I'm placing the bottom reed switch 4in above the window sill so no fingers/hands will get stuck(the window is real high up, about 6-7ft). The window is going to be connected to the motor with a pulley so if something does get stuck it won't have a lot if squeezing force... I only chose the worm geared motor because it doesn't use power to keep the window open
I feel like that should cover the safety aspect of this project... The code/program is where I need the most help.
This runs the motor for two seconds in one direction and then two seconds in the other direction.
.
#define MOTOR 4
#define DIR 5
void setup()
{
pinMode(MOTOR,OUTPUT);
pinMode(DIR,OUTPUT);
digitalWrite(MOTOR,HIGH); //motor on
delay(2000);
digitalWrite(MOTOR,LOW); //motor off
delay(10); //wait for spikes to dissipate
digitalWrite(DIR,HIGH); //reverse direction
delay(10); //wait for spikes to dissipate
digitalWrite(MOTOR,HIGH); //motor on
delay(2000);
digitalWrite(MOTOR,LOW); //motor off
delay(10); //wait for spikes to dissipate
digitalWrite(DIR,LOW); //relay off
}
void loop()
{}
this should allow you to make sure it goes up and down.
once you know it works, then the details of how and why it should move come in to play.
That's the code I was originally using... It runs off a timer. or was that code just to make sure the circuit is functioning correctly? If so I think the circuit is functioning correctly
Sorry. Should my question been asked in the "Programming Questions" not "Project Guidance"... The OP(Original post) was to get started on how the layout of the window was going to be, now this thread is help with the code.
I was going to mention it but I didn't know how to link just the Threads that were being asked from the OP.
so please let's just-stick to the code,
There were code suggestions in the other Thread and by starting a new Thread someone is just going to waste time making the same suggestions again.
The problem is not where you have this Thread just that it would have allowed everyone to see all of the project if you had just continued in the other Thread.
Were any of the code suggestions in the other Thread useful ether because they helped or because they illustrate something you definitely don't want. If so, which ones?
It is because I was attempting to help by writing the code, and I was having a hard time finding the time to continue. I suggested he start a new thread, so blame me.
There now seems to be a software discussion on your main Thread.
I suggest you click Report to Moderator on this Post (doesn't work from one of your own posts) and ask the moderator to merge this with your other Thread.