ArchiBots07
Project 1: Responsive Space Project
The Anti-Theft Box
Goal:
The Anti-Theft Box is based upon the idea of putting something of important value on the top plate and an alarm going off when it is removed.
The specifications for building this type of device are simple:
1. Set up the Arduino with proper circuits shown in the diagram below:
Instructions:
A: Hook up the wires so that the red wire ( or the postively charged wire) of the speaker is in the Ground pin and the other wire is in pin 13.
B: Next plug in the switch. Do this by again putting the middle wire in the Ground pin, the far right wire should go into the 5V power source next to the Ground, and then final wire in Pin 7.

2: Open Arduino software program and type in the following code:
int speakerPin = 13; // choose the pin for the speaker
int inPin = 7; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
void setup() {
pinMode(speakerPin, OUTPUT); // declare speaker as output
pinMode(inPin, INPUT); // declare pushbutton as input
}
void loop(){
val = digitalRead(inPin); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
digitalWrite(speakerPin, LOW); // turn speaker OFF
} else {
digitalWrite(speakerPin, HIGH); // blink the speaker and go OFF
3: Push the compile button, then the reset button on the Arduino, and finally the upload button to send the code to the Arduino.
4: The switch and speaker should work. Test it out by pushing down the switch and then letting it go. When you let it go the speaker should go off.
5: Build a 6 inch by 6 inch box, then build an extra floor plate so that there is a 2 inch gap between both the floors. Place the arduino and the speakers into the box and place the second floor plate on top of it. Make sure you allow enough room for the arduino to not get disconnected due to manufacturing problems of the box. Then cut out a hole big enough for the speaker and place the speaker within that whole. You have now successfully built THE ANTI-THEFT BOX!
6: Try it out!
ewwww BUGS:
The main problem with THE ANTI-THEFT BOX is that when the switch goes off the power turns off also due to the direct circuit. This becomes a potential problem when trying to incorporate the switch into other projects.
The design of the project is very simple, if I were to change or improve anything it would be the complexity of this project. I would try to add more inputs and outputs, and try and use the different types of sensors. Also, I would attempt to put this type of mechanism in different place and try and see what implications might happen.
Project 2: Musical Instrument
Mouse Trap The Musical! ![]()
Goal: To create an interactive toy in which as one plays with it, the toy creates musical noises. Using the theme of Mouse Trap, one can establish this relationship easily.
The specifications for building this type of device are simple:
1. Begin by playing MOUSE TRAP!!!
2.Start building the base for the pulley system and other components. They are essential for the toy to play at all. First cut two rolls of 2 inch wide cardboard tubes. Then create a band from glue and paper towels by placing glue on half of a paper towel and then folding it in half. Place the circular band around the two cardboard tubes. Now its time to stabilize the pulley system. Connect the two cardboard tubes to the base of the project. Make sure you allow space for other components to fit. Next, place one of the cardboard tubes on a spindle system and then make sure it spins. Then do the same for the other tube but place the tube 4-6 inches above the actual base. Next add little compartments on the band to hold multiple marbles. Now its time to create the shoots. Create two metalic shoots positioned downwards so that a marble has enough momentum to go down each one of them. On the first shoot cut a hole at the end of it so that the marble with fall and then go down the other shoot. (Make sure you test out the marble coming down from the band to the shoot to see if it actually works. It is essential that it's placement is perfect.) Now its time to start coding and hooking up equipment to the mouse trap.
3. Begin by taking your Arduino out.
For this project you are going to need the following equipment: push button, click switch, speaker, resistor,potentiometer, servor motor, DC motor, 9V batterylots of wire, and a breadboard.
Lets Begin!!
A: Start off by plugging in the speaker. Do this by putting the positively charged wire in the Ground and then the other wire in pin 13.
B: Now lets give the breadboard some power! Hook up a wire from the 5V power pin to the + any where on the breadboard. Next put a resistor from that same pin to any row on the breadboard. Next get some more wire and place one end in the Ground and the other on the breadboard.
C: Its Push Button Time!! Connect the Arduino to the breadboard by getting wire and plugging it into pin 7 and then the other end to where the resistor was placed. Now get the positively charged wire of the push button and place it in that same pin. Place the other wire in the same row you put the wire from the ground on the bread board to. You now hooked up your push button!!!
D: Click Switch Baby!! Place the middle wire of the click switch in the same row as the Ground wire and other wire of the push button switch. Next Place the positively charged wire in the + column on the breadboard to give it power. Then place the other wire in the same row as the beginning power wire with the other push button switch.
E: Motor Power!!!! Let's plug in the servor motor. Begin by placing the positively charged wire in pin 6 and then the other in the 9V pin. Next, it's time to give the DC motor some power. Place the wires from the motor to the battery directly + to - and - to +, and that should get it going automatically. You have now successfully plugged in everything!!!
Let's Get Our Code On!!!

4. Open the Arduino Program and type in the following code:
int speakerPin = 13; // choose the pin for the SPEAKER
int inPin = 7; // choose the input pin for the PUSHBUTTONS
int val = 0; // variable for reading the pin status
int servoPin = 6; //choose the pin for the SERVOMOTOR
int minPulse = 500; //minimum SERVOMOTOR position
int pulse = 0; //time to pulse the SERVOMOTOR
int lastPulse = 0; //time in milliseconds of the last pulse
int refreshTime = 20; //period: time between beginning of pulses
int analogValue = 0; //variable for reading the POTENTIOMETER
int analogPin = 0; //analog pin where to plug the POTENTIOMETER
void setup() {
pinMode(speakerPin, OUTPUT); //declare SPEAKER as output
pinMode(inPin, INPUT); // declare PUSHBUTTONS as input
pinMode(analogPin, INPUT); //declare POTENTIOMETER as input
pinMode(servoPin, OUTPUT); //declare SERVOMOTOR as output
pulse = minPulse; //set the SERVOMOTOR position to the minimum (zero)
Serial.begin(57600); //set up the serial communication
}
void loop(){
val = digitalRead(inPin); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
digitalWrite(speakerPin, LOW); // turn SPEAKER OFF
} else {
digitalWrite(speakerPin, HIGH); // beep the SPEAKER and go OFF
}
analogValue = analogRead(analogPin); //read the POTENTIOMETER
Serial.print("Raw Pot Value: ");
Serial.println(analogValue); //print POTENTIOMETER values back to the computer
pulse = (analogValue/10) * 19 + 500; //scale input values to SERVOMOTOR range
Serial.print("Pot to Pulse: ");
Serial.println(pulse); //print SERVOMOTOR pulse values back to the computer
Serial.println("***");
//pulse SERVOMOTOR if the refresh time of 20 milliseconds has passed
if(millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); //turn SERVOMOTOR ON
delayMicroseconds(pulse); //Pulse is in microseconds while lastPulse is in milliseconds
digitalWrite(servoPin, LOW); //turn SERVOMOTOR OFF
lastPulse = millis(); //save time of the last pulse for 'if' block checking
}
}
5.Now its time to place the equipment into your made base. Begin by placing the push button switch underneath the hole of the shoot where the ball is supposed to drop. Next place the other click switch directly in front of the area in which the marble initially hits when coming off of the band. Now hook up the DC motor to the pulley system by attaching it to the bottom tube and placing the smaller end of the motor into the pulley so that it turns it automatically. Finally, the servo motor should be placed at the front of the first cardboard tube. Add extra length to the motor so that when you hook up your potentiometer (the knob) you can control it and knock the balls in.
NOW ITS TIME TO PLAY MOUSE TRAP THE MUSICAL!!!
ewww BUGS:
One of the switches was not placed accurately enough so as to be played by the metal marble and the metal marble did not move out of the ramp by itself, so it had to be pushed by a servomotor controlled manually by a potentiometer, which was not accurate so as to keep the loop running constantly.
If I were to change or improve anything in the project it would the effective nature of the servo motor to push the balls onto the band, and also the push buttons being on a direct circuit to the power. This caused many problems and could have been resolved by coding the servo motor instead of doing it manually.
Project 3 -State project

Code
int state = 0; // Variable to hold the current state.
int pressed; // Indicates which button was pressed.
int b1 = 0; // I/O pin number for first button.
int b2 = 2; // I/O pin number for second button.
int b3 = 4; // I/O pin number for third button.
int val1; // Holds the value of the first button.
int val2; // Holds the value of the second button.
int val3; // Holds the value of the third button.
int testLEDPin = 13;
void setup() {
pinMode(testLEDPin, OUTPUT);
pinMode(b1, INPUT);
pinMode(b2, INPUT); // Setup these pins as INPUT signals.
pinMode(b3, INPUT);
pinMode(b1, LOW);
pinMode(b2, LOW);
pinMode(b3, LOW);
Serial.begin(9600); // Connect back to the PC. }
void loop() {
pressed = getButton(); // Calls the method that determines which button was pressed. Store the result in "pressed".
updateState(); // Calls the method that changes the state based on the input. }
/* * getButton() method waits for a button to be pressed,
* determines which button was pressed and then returns
* the button number to the main loop.
*/
int getButton() {
//val1 = LOW;
//val2 = LOW; // Initialize all button values to LOW.
//val3 = LOW; // These variables will store whatever the DigitalRead returns.
// This "while" loop waits for a button to be pressed.
//while ((val1 || val2 || val3)==HIGH) { // Conditions is that all three "vals" must be "LOW".
// As soon as one of them is "HIGH", the program exits the loop.
// BTW: "HIGH" is the same as "TRUE"; "LOW" is the same as "FALSE".
Serial.print("^ "); // Print a "^ " while waiting for a button to be pressed (button is ^ up).
val1 = digitalRead(b1);
val2 = digitalRead(b2); // Get the values of the buttons.
val3 = digitalRead(b3);
//if(val1==HIGH) Serial.println("b1 off");
//if(val2==HIGH) Serial.println("b2 off");
//if(val3==HIGH) Serial.println ("b3 off");
//Serial.println();
/*
Serial.print("((");
Serial.print(val1);
Serial.print(",");
Serial.print(val2);
Serial.print(",");
Serial.print(val3);
Serial.print("))");
Serial.println();
*/
//}
// These "if" conditions determine which button was pressed to come out of the "while" wait bit above.
if (val1 == LOW){
pressed = b1;
Serial.print("pressed ");
Serial.print(pressed);
}
else{
Serial.println("else statement 1");
if (val2 == LOW){
pressed = b2;
Serial.print("pressed ");
Serial.print(pressed);
}
else{
Serial.println("else statement 2");
if (val3 == LOW) {
pressed = b3;
Serial.print("pressed ");
Serial.print(pressed);
}
else{
Serial.println("NO BUTTONS PRESSED");
}
}
}
digitalWrite(testLEDPin, HIGH);
// This "while" loop waits to be sure that the button was released.
while (digitalRead(pressed)==LOW) { // Condition is that "digitalRead(pressed)" is TRUE.
Serial.print("_ "); // Print a "_ " while button is still pressed."
}
digitalWrite(testLEDPin, LOW);
return pressed;
}
void updateState() {
}