Lacking Knowledge

I upgrade my daughters Backyard play house with a mechanical window , so it can open or close. The thing is I followed the schematics and the example program from this link .http://www.me.umn.edu/courses/me2011/arduino/technotes/dcmotors/bidirectional/bidirMotor.html and ran into a problem, I had to modify the example program code so the Up/Down timeing could reach what my little daughters hart Desired(that was a pain in the ***). I want to add a couple of things to the same Schematic on the provided link , a button so my daughter won't have to press the reset button on the arduino board all the time and two ir sensors(sharp gp2y0a21yk0f analog distance sensor) so the window can stop at the locations of the the sensors.

If anybody reading this knows how to do it,can you modify the program code and Schematic to do what I want? :'( Help will be very appreciated by her and myself.

I think we can go without an encoder? Beside I don't have one... I like what you recommend the 1 push button to controll the U/D and the ir sensors to have them stop at point A and B. Do you think I could somehow connect the 2 ir sensors and button to the same schematics/diagram as in the link I showed? I'm new to arduino.but I do understand a little of programming... But never in a 100 Years will I be able to code what I'm asking for. A little FYI idk if this matters but I'm using a arduino UNO rev 3

Here's the link from where I purchase the ir sensor http://www.amazon.com/gp/aw/d/B00IMOSEJA?pc_redir=1401346347&robot_redir=1

Thanks for the help...

Wouldn't it be much easier to open and close a dolls-house window with a servo? It would certainly be much easier to program.

...R

I thought servo's couldn't do multiple 360's..? I'm using a 12vdc with a built in worm gear in the gear box(8rpm), so it won't need to use power to keep the window open(windows about 7-8lbs). How easier is it to program servo then a motor? Can servos go both ways without haveing to build your own Circuit or h-brigde, if so I'll just stick to our original plan of using 1 Button to controll the U/D and two ir sensors( http://www.amazon.com/gp/aw/d/B00IMOSEJA?pc_redir=1401346347&robot_redir=1 ) to have the window stop at the ir sensors locations... I wouldn't even know how Integrate the button and sensors to the Schematics I followed from this link http://www.me.umn.edu/courses/me2011/arduino/technotes/dcmotors/bidirectional/bidirMotor.html

I hope I'm not wasting y'all's time with my Shenanigans.

ProjectNoWork: I thought servo's couldn't do multiple 360's..? I'm using a 12vdc with a built in worm gear in the gear box(8rpm), so it won't need to use power to keep the window open(windows about 7-8lbs).

I thought you meant a 1/12 scale play house with windows that rise and fall 20 or 30mm - not one that your daughter could get into. For the loads you are talking about the motor and worm gear are probably best.

...R

PS Go to your local white goods retailer and get your daughter the cardboard box from a fridge. She will have much more fun.

...R

HazardsMind, I'm try that, thanks... I'll just have to wait till I get the sensors. Yea, I saw the file and downloaded it to arduino file but only found 1 code...

Robin2, right that would be much easier. Lol

I know this isn't what you have already, but for an outdoor toy, I'd go with a magnet and a couple of reed switches to detect fully open and fully closed.

My wife has a kindergarten in our home and has a playhouse in the backyard, it is covered in dust after only a few sunny days. Not enough to really notice, but I expect it would play havoc with the Sharp distance sensor.

The magnet and reed switches could be covered in mud and still work.

As for availability, any place that sells alarms should carry reed switches (aka reed sensors or magnetic sensors) and magnets. Hardware stores, Radio Shack, etc.

Note that I'm -not- talking about hall effect sensors, although you could use those, too. A reed switch is just two contacts in a glass tube, made of a plated ferrous material. A magnet brought close causes them to snap together, just like a nail stuck to a magnet will attract other nails. You connect it to your Arduino the same way you connect a pushbutton, and read it the same way.

I should point out, those Sharp sensors are not go-no go sensors. IE, they don't just switch the output when something blocks them. You are thinking of optointerrupter or optoreflective sensors. The Sharp sensors you bought are distance sensors, they output an analog voltage that is a nonlinear representation of how close something is to the sensor.

So you could use them, but it might be a bit more complex than a simple switch.

Could you post your code as you've changed it?

I noticed that the sample code on that page has nothing in void loop(). I'm a hardware guy, not very experienced at programming, but that doesn't seem right. It is going to complete the process once and stop, which I guess is the idea.

I think I can do better.... I know other people here can. And we'll get rid of that stupid use of delay().

Polymorph, that changes everything. So what type of reed sensor's should I get.... Will it be able to do everything I've asked for? If so your way is the best way. I live out in the Country and dust is everywhere. About the code I was hoping to ran into a already made code/program on the web that'll cover my needs... I know a little something about c,c++ but no way in hell would I be able to write my own code

Powered windows in a child's play house would make me worry about squashed fingers or heads getting chopped off. I suggest that if you go ahead with this, you ensure the mechanism can't generate enough force to hurt anyone. I think you'd also want to assume that children would grab hold of the window and override whatever you're using to operate it - direct drive from a servo would probably result in stripped gears pretty quickly in that case, so I think you'd need to incorporate a 'servo saver' into the operating linkage.

I don't know how much force you're expecting this thing to apply, but I suggest you aim to design the window mechanism so that it is neutrally balanced so the servo mechanism isn't lifting or supporting any weight.

I agree with PeterH. A worm gear is not a good idea for this, because you can't force it backwards. You could add some kind of slip-clutch to it. As for not pinching small fingers, a current sensor could detect when excessive torque is being drawn and stop the motor. Or a resistor could be added in series with the motor, but you'll just have to cut and try to figure out what value is right.

I'll just leave a Clearance of 1-2inches so her fingers won't get crushed while the window goes down... Polymorph would these reed's be easy to use? http://www.amazon.com/gp/aw/d/B00J8AFP3A/ref=redir_mdp_mobile

ProjectNoWork: I'll just leave a Clearance of 1-2inches so her fingers won't get crushed while the window goes down

How about if instead of fingers caught in the gap, it's an arm - or a neck? I think it pays to be paranoid when you're dealing with something this important.

PeterH, thanks for the concerns... But the window is high up, her arm neck Etc wouldn't be able to reach that high up. The only part that would be able to reach the edge of the window frame are her hands/finger tips,if she's jumps up.

I think a reed switch would work very well for this project. You could use one reed switch to stop the motor when the window reaches the top, and another reed switch to stop the motor when it reaches the bottom. You can place the reed switches anywhere you want along the window frame to indicate the extremes of open and closed - this would allow for the small clearance that you mentioned for protecting delicate, inquisitive fingers.

Reed switches are literally just like any other switch as far as the Arduino is concerned. In the following example, the reed switch attached to digital pin 2 could represent the open position of the window, the reed switch attached to digital pin 3 could represent the closed position of the window. You would probably want to activate the internal pull-up resistor for the two digital pins, or attach a 10k resistor between the reed switch on each digital pin and the 5V supply on the Arduino. This resistor "weakly" pulls the switch up to +5V, so that if the switch is open, it will have 5V on it (through the resistor) and thus will register HIGH if not pressed, and LOW if pressed.

http://www.amazon.com/Amico-MKA-10110-10-15AT-Magnetic-Switches/dp/B008DTJORK/ref=sr_1_1?ie=UTF8&qid=1401658176&sr=8-1&keywords=reed+switch

http://www.amazon.com/Directed-Electronics-8601-Magnetic-Switch/dp/B0009SUF08/ref=sr_1_2?ie=UTF8&qid=1401658176&sr=8-2&keywords=reed+switch

http://www.amazon.com/Generic-Cylindrical-Plastic-Proximity-Magnetic/dp/B00EQ20A30/ref=sr_1_4?ie=UTF8&qid=1401658176&sr=8-4&keywords=reed+switch

http://www.amazon.com/951WG-WH-Ademco-Stubby-Recessed-Contact/dp/B001UKY1A4/ref=sr_1_7?ie=UTF8&qid=1401658176&sr=8-7&keywords=reed+switch

Now the big question is where do I find a code that'll fit my needs? I need 1 button to control the U/D of the 12vdc motor, and the reed sensors to have the windows stop while going up or down... I found a code that I think will help for the reed sensors but idk? I know this code isn't going to help cause it only has 1 reed sensor in the program?

const int switchPin = 2; // // Reed switch to digital pin 2 int ledPin= 13; // // LED is on digital pin 13 int state = HIGH; // the current state of the output pin int reading; // the current reading from the input pin int previous = LOW; // the previous reading from the input pin

void setup() { pinMode(switchPin, INPUT); // switchPin is an input pinMode (ledPin, OUTPUT); // ledPin is an output digitalWrite(switchPin, HIGH); // Activate internal pullup resistor Serial.begin(9600); }

void loop() { int reading = digitalRead(switchPin); Serial.println(digitalRead(switchPin)); // Display current value delay (200); if (reading == HIGH && previous == LOW) { if (state == HIGH) state = LOW; else state = HIGH;

}

digitalWrite(ledPin, state); previous = reading;

}