User:Batmaneatsgrass/Useless Baby Box

=Problem= Create useless box that uses a baby to turn off the switch. The baby's arms must be the ones to do it, so it should look like the baby is popping out of the box and turning the switch off itself.

=Concieve= The idea for the box came from the previous project where the requirement was to have something that turns a light switch off. Here, there is a light as well as a switch that turns it off. There will be a switch outside of a box. Once the switch is turned on, a light will then turn on. Then, a baby will come out of a box, turn the switch off, which will turn the light off, and will go back into the box.

=Materials=
 * doll baby
 * shoe box
 * arduino uno
 * adafruit motorshield
 * stm-100 stepper motor
 * servo motor
 * wire
 * AA batteries (8)
 * 9V batteries (2)
 * LED strip light
 * wire
 * wood glue
 * hot glue
 * wood
 * zip ties
 * electrical tape

=Design=



Box

 * Three large pieces of wood are glued underneath the shoebox for stability. The wood will prevent the box from moving when the baby comes out to turn the switch as the cardboard to too light and may be influenced. The middle piece of wood goes further out than the others and on to it another piece of wood is screwed that is 5 inches higher than the top of the box when it's closed.
 * The switch is screwed onto the piece of wood that's in front of the box.
 * A lid is carved out of the top of the box from where the baby would come out

Switch/Light

 * Behind the box another piece of wood is glued onto which the roll of LEDs is placed.
 * A wire connects the LEDs to the a 9V battery and to a switch.

Motors

 * Stepper is on a 2 inch block of wood on the ground
 * Big gear on stepper has stick glued to it which holds up baby
 * Wire goes inside baby's arm and is glued to servo
 * Servo is put into body of baby

Baby

 * Baby's legs are cut off to make it light weight and to not interfere with motors
 * Some stuffing is taken out to make room for servo

Processor

 * Motor shield is connected to arduino. The voltage in pins of the shield cannot go into arduino unless the arduino's death is desired.
 * Both stepper and servo are connected to adafruit motor shield
 * Photoresistor detects the light when the switch turns it on and is attached to the available pins on the motor shield. If there is a large change in light, its resistance changes and a signal is sent to the arduino which tells the motor to move the baby.

=Implement=

Now
The box frame is completely made. The place where the stepper motor should go is marked (insode box) and the switch is situated in the correct location (outside of box) - if the stepper with the attached baby goes into the marked spot, the baby's arm and servo will be able to come high enough to turn the switch off. The baby and servo are already attached. The motor shield is connected to the arduino with the 5V and 3.3V pins out.

Code
The following code was created by Vincent Pugliese for the Useless Baby Box. The numbers you see below are actually "#" but wikiversity converts them into numbered list


 * 1) include 
 * 2) include 
 * 3) include 

// Connect a stepper motor with 200 steps per revolution // to motor port #2 (M3 and M4) AF_Stepper motor(200, 2); Servo myservo1; //create servo object void setup { pinMode(A0, INPUT); //photoresistor myservo1.attach(2); //servo signal pin Serial.begin(9600); motor.setSpeed(10); //set speed to 10 RPM } void loop { float R = analogRead(0); //set photoresistor value to variable Serial.println(R); //print value if (R > 275.0)//value must be adjusted through experimentation {   motor.step(55, FORWARD, SINGLE); //raise stepper to 99 degrees (55 steps) delay(1000); //pause 1.0 seconds myservo1.write(0); //move servo to 0 degrees delay(1000); //pause 1.0 seconds myservo1.write(140); //move servo to 140 degrees delay(2000); //pause 2.0 seconds myservo1.write(0); //move servo to 0 degrees delay(1000); //pause 1.0 seconds motor.step(55, BACKWARD, SINGLE); //return stepper to initial position } else {   delay(1000); } }

Problems

 * Stepper motor isn't working
 * LED strip lights are gone
 * Part that was attached to back of box for holding LEDs broke
 * Gear pops off from servo every once in a while
 * Box isn't exactly aesthetically pleasing

Next Steps

 * 1) Buy new stepper motor
 * 2) Attach to marked spot inside box
 * 3) Attach gear with baby to it
 * 4) Connect it to motor shield
 * 5) Buy LED strip lights
 * 6) Glue piece of wood to back of box where lights can hang
 * 7) Connect lights to switch and 9V battery
 * 8) Find way to keep servo motor gear from falling off every now and then
 * 9) Possibly replace the one servo with two servos (one for each arm)
 * 10) Check what resistors are needed for...
 * 11) Photoresistor
 * 12) Stepper motor
 * 13) Servo motor
 * 14) Fix code if there are problems