If you are using an external timer and the arduino is only Controlling the stepper, the question wouldn't be "can this be done with an Arduino" but rather why use an Arduino?
Ok, to answer your question(s)...
Question: "dont know if what i want is possible with a single arduino"
Answer: Yes, it is possible.
Incorrect assumption: "problem is each power on i need to arduino to run different sketches."
An Arduino can only have one sketch. End of discussion. That sketch however can do a Million different things (ok, maybe I exagerated by 5%).
On Startup, the sketch should detect if the door is either open or closed. Maybe using a limiting Switch. (If the top Switch is closed, the door is open. If the bottom Switch is closed, the door is closed. If neither is true...) Alternatively, the Arduino could detect if it's light outside and open the door. If it's dark, it Closes the door. Your Imagination is the limiting factor here, not the Arduino.
Since you are using a stepper Motor, step one direction to move the door up, the other moves the door down.
The while loop is not necessary, it is also blind and deaf and assumes it will always be right.
Arduino code has
void setup()
{
}
void loop()
{
}
The loop function runs over and over, no stop.
Inside of loop() you can detect buttons/sensors (Inputs) in separate code for each and set flags to trigger Outputs.
Inside of loop() you can place code to run leds/motors (Outputs) inside of if (trigger).
You should have sensors to know when the door is full open/closed and something to trigger for desired position.
Also if the door slides sideways on rails the motor won't have to lift it. Or you could counterweight the door.
GoForSmoke:
The while loop is not necessary, it is also blind and deaf and assumes it will always be right.
Arduino code has
void setup()
{
}
void loop()
{
}
The loop function runs over and over, no stop.
Inside of loop() you can detect buttons/sensors (Inputs) in separate code for each and set flags to trigger Outputs.
Inside of loop() you can place code to run leds/motors (Outputs) inside of if (trigger).
You should have sensors to know when the door is full open/closed and something to trigger for desired position.
Also if the door slides sideways on rails the motor won't have to lift it. Or you could counterweight the door.
open close magnetic sensors seem needed. i was wanting to just time the stepper to fully open and close, which i still can but need the sensors to tell the arduino its state on the next power up. i dont want it on powering mt steppers all day waiting to close at night.
i also had idea of a revolving disc with chicken size holes so every time it powers up the stepper takes it to an open hole then at night to a closed hole. no sensors needed. might require a 32 size motor unless it was very light weight. trying to have as few variables for failure.
You're going to want sensors just to know if a chicken is in the doorway before you close it.
With a little time and study you can DIY IR-reflect, IR-beam and capacitive sensors out of cheap components or scrap.
Security Hall switches run about 50 cents each if you shop and for those you want weak magnets.
Capacitive sensing can get you the same with more code but literally wire and scrap metal to make the sensor.
Cap sense done one way:
I have a pin with a wire to a metal plate... a small piece of can metal will do.
I ground the pin for a short bit, all goes LOW.
Then I use the internal pullup mode of the pin to charge the pin, wire and plate while seeing how long it takes for the pin to go HIGH, in usually a small fraction of a millisecond.
I bent a paperclip to make a loop with a prong than covered the loop in foil and stuck the prong in the pinhole to test this out, get an idea of what code I could make work.
If you position another metal plate close (you not close) or put your finger close/touch, the charge up time will increase. You might even be able to pick up a nail in a piece of wood if it's close enough but the big fun might be detecting a chicken. Yes, chickens have electric field just like you.
rallysmurf:
So, i am a learning newb but know some but after getting into it though
dont know if what i want is possible with a single arduino.
what i want-
my 17 stepper to spool up paracord vertically a lightweight screen door on roller drawer sliders
with while loop.
use a belkin wemo wifi in timer mode to turn on the arduino.
problem is each power on i need to arduino to run different sketches.
one door up. one door down.
IDEAS? other hardware that might be better?
alex in ama
GoForSmoke:
You're going to want sensors just to know if a chicken is in the doorway before you close it.
With a little time and study you can DIY IR-reflect, IR-beam and capacitive sensors out of cheap components or scrap.
Security Hall switches run about 50 cents each if you shop and for those you want weak magnets.
Capacitive sensing can get you the same with more code but literally wire and scrap metal to make the sensor.
Cap sense done one way:
I have a pin with a wire to a metal plate... a small piece of can metal will do.
I ground the pin for a short bit, all goes LOW.
Then I use the internal pullup mode of the pin to charge the pin, wire and plate while seeing how long it takes for the pin to go HIGH, in usually a small fraction of a millisecond.
I bent a paperclip to make a loop with a prong than covered the loop in foil and stuck the prong in the pinhole to test this out, get an idea of what code I could make work.
If you position another metal plate close (you not close) or put your finger close/touch, the charge up time will increase. You might even be able to pick up a nail in a piece of wood if it's close enough but the big fun might be detecting a chicken. Yes, chickens have electric field just like you.
sounds interesting but not needed. you know a lot about sensors, application and functionality. I know more about chicken. mine go up at times like clockwork.
I got me a 23 long shaft stepper and fanged hub to mount my door wheel on.
so ever cycle of the power on arduino will rotate it 180 deg.
i am using a timer embed in my belkin WeMo smart plug switch.
This method is used for others who want to make a chicken door as easy as possible with the least programing and most features with off the shelf hardware.
ill be posting more build photos as it comes along for other curious chicken door makers.
You only need the Arduino to run the motor in the same direction and duration each time?
I'm not so sure you need the Arduino if that WeMo is as good as I think it is, but an ATtiny45 is likely enough to run that.
I'm more into cutting the system cost. How much does WeMo cost compared to a cheap RTC module? Stepper vs DC motor?
I'm interested in the fanged hub. Gear? Sprocket? The door wheel is just great, BTW.
The birds want out at first light? Always in by dark?
thanks, it is simple. Yeah 180deg rotation each power on but i want it to be exact so it lines up each time.
turns out the WeMo signal want strong enough o fine my router and when
i hooked up a range extender it couldn't find it. Soooo. i am using a standard
digital timer for one min on to cycle it.
i used a 48t fanged timing pulley as a hub and just drilled 5 through holes
to mount my wheel to. its a bit weighty 3/4 plywood so i am using accelstepper
to get it moving.
#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(1,9,8); // 1 is ground, 9 is PUL-, 8 is DIR-
void setup()
{
stepper.setMaxSpeed(80.0);
stepper.setAcceleration(40.0);
stepper.runToNewPosition(110);
}
void loop()
{
}
i still need some help to get exactly 180 out of the motor.
have you used this library?
You could turn the big wheel with the hole by turning a small wheel on a DC motor shaft against it and using position sensors (magnet and reed or Hall switch or a dozen others) to serve as stops. You get max leverage on the wheel edge. If the wheel had teeth, you could turn it very solidly with a worm gear.
You only have to turn the wheel 90 degrees to open or block the door. If you cut 2 holes, your motor only has to run 1 direction so goodbye H-bridge and speed control, just position the sensors right and stop every 90 deg.