User:Tjaw94/ENES 100/project 2

Project Preference

 * Useless Box
 * Makerbot
 * escher

Problem Statement
The project we will be working on is designing a Useless Box. The Useless Box is to complete various tasks which do nothing for anyone. It is a box that that completes random tasks that are programmed in the Arduino.

Project Plan
In the next few weeks we will be researching on how to use an Arduino. We will be learning to how to program motors, lights and other fun things to the Arduinio. We will also be building a box for the useless box to reside in. Also, we will be designing the shape of the box so that the box will hold all of our actions we want it to do.

Week 1
This week Arduino's were being learned. Programming Arduino's have to be extremely specific. There are different brands of Arduino's that run differently in the Arduino programming system on the computer. There is a website called Ardunino.cc which helps with downloading the operating system and helps with programming. The best way to learn how to learn arduino is to play around with it and learn from the website. Another a website which helps with programming is called Ladyada.net. This website is a tutorial on how to program different types of electrical components such as lights, buttons, motors, buzzers, etc.

Week 2
This week I learned how a buzzer is programmed onto an Arduino. I also learned that the Arduinos can not play frequencies lower than 31 Hz. They can play all the way up to about 10000 Hz. I also learned that when I buzzer is going off it can change frequencies and go from 31 Hz up to about 10000 Hz. The Arduinos also only use the measurements in Hertz for sound. Also you can not program more than one buzzer at a time or it will ignore the second buzzer.

Week 3
This week i designed a shape for our box to see how the motor, breadboard, and arduino would fit in the box. I determined that a jewelry box would be a good size for our useless box. Also Cutting little slits in the box where the opening is would help cause less friction and it would make it easier for the arm to open and turn the switch off. I also thought that we would have to drill a hole in order for the switch to be outside of the box and it would make it more presentable. I also thought of putting the buzzer inside the box to make a noise that one would not expect to hear when the switch is turned on.

Week 4
This week i my task was to find a way to make the piezo buzzer louder because it was barely audible. I found 2 solutions to the problem. One of them is to get a transformer for the sound to be amplified. The other soultion i found was to make sure the buzzer is getting enough current to the buzzer from the arduino. After i found these two solutions I created a code which works with a switch/buzzer. creating this program helped me understand a little better on how we are going to put together all of the codes for each accessory. https://www.youtube.com/watch?v=0g4t7EV2aCU

Week 5
This week was a successful week because a switch was put together with a light and a buzzer which alternate between what gets turned on and what stays off. For example when the switch is turned on it the light comes on, but the buzzer stays off. When the switch is turned on again the buzzer turns on while the light stays off. It is on a continuous loop of what gets turned on and what stays off. Also this week thinking about on how to add a servo motor code to the program that was created this week.

Week 6
This week the switch light and buzzer are being combined with the motor sketch. The motor sketch is being added to the program in the picture above. The Adding of the motor to the program is a lot harder than anticipated. The motor sketch has a servo library which has to be added and it makes the servo motor read the program to operate the servo motor. Also finding the places to add the motor sketch were a little confusing because when the motor is on it has to turn the switch off and retract back to its original position.

Week 7
This week the motor was incorporated with the light buzzer and switch sketch. So when the switch is turned on the light comes on and the motor turns on and comes out to turn the switch off which will turn the light off also. The motor then returns back to its original position. When the switch is turned on again the same thing happens except the buzzer comes on. The next step that would happen would be to add the arm to the servo motor so it actually works. Also another step would be to maybe add another feature to the box. Here is a link to what it looks like right now: https://www.youtube.com/watch?v=GLy_aGRpvjc&index=1&list=UU4AqbA5v9GntTe2Ya7NxeLw Here is what the code looks like:

Servo armservo;
 * 1) include 

int pos = 0; int buttonPin = 2;                               // Button is pin number 2 int ledPin = 4;                                  // Buzzer is pin number 4 int ledPin2 = 3;                                 // The light is pin number 3 int buttonState = 0;                             // The Button state 0 means the button/switch is off int count =0 ;                                   // An int have a value of either 1 or 0 for turning on either the LED or Buzzer void setup { pinMode(ledPin, OUTPUT);                        // For PIN 4 (BUZZER) only 5V can be output pinMode(buttonPin, INPUT);                     // The button is the input so that if it detects a voltage it turms the LED or Buzzer ON  pinMode(ledPin2, OUTPUT);                       // For PIN 3 (LED) only 5V can be output armservo.attach (9); } void loop { buttonState = digitalRead(buttonPin);           //  ButtonState has a value of either HIGH or LOW depending on if the switch is on (HIGH) or off (LOW) while( buttonState == HIGH && count ==0){       // When the button is on and the count is 0, the buzzer turns on, but the light stays off digitalWrite(ledPin, HIGH); for(pos = 0; pos < 180; pos += 1)              // goes from 0 degrees to 180 degrees {                                             // in steps of 1 degree armservo.write(pos);                         // tell servo to go to position in variable 'pos' delay(15);                                  // waits 15ms for the servo to reach the position }   for(pos = 180; pos>=1; pos-=1)                 // goes from 180 degrees to 0 degrees {      digitalWrite(ledPin, LOW); armservo.write(pos);                         // tell servo to go to position in variable 'pos' delay(15);     // waits 15ms for the servo to reach the position }                     // Turns on Buzzer buttonState = digitalRead(buttonPin);        // Keeps reading the PIN 2 to see if it has changed value from HIGH to LOW if so the if statement changes the value on int count to 1 if (buttonState == LOW){                     // the while loop ends when the switch is turned off and thus changes the int count to 1 so that next time the switch turns on only the LED will light up    count =1; } }  while (buttonState == HIGH && count ==1){       // When the button is on and the count is 1, the LED turns on, but the buzzer stays off digitalWrite(ledPin2, HIGH); for(pos = 0; pos < 180; pos += 1)                // goes from 0 degrees to 180 degrees {                                             // in steps of 1 degree armservo.write(pos);                         // tell servo to go to position in variable 'pos' delay(15);                                  // waits 15ms for the servo to reach the position }   for(pos = 180; pos>=1; pos-=1)                 // goes from 180 degrees to 0 degrees {        digitalWrite(ledPin2, LOW); armservo.write(pos);                         // tell servo to go to position in variable 'pos' delay(15);                                  // waits 15ms for the servo to reach the position }   digitalWrite(ledPin2, HIGH);                  // Turns LED on    buttonState = digitalRead(buttonPin);         //Keeps reading the PIN 2 to see if it has changed value from HIGH to LOW if so the if statement changes the value on int count to 0 if (buttonState == LOW){                     // the while loop ends when the switch is turned off and thus changes the int count to 0 so that next time the switch turns on only the LED will light up    count =0; } }    digitalWrite(ledPin, LOW);                    // if the switch is off then the both the LED and Buzzer remain off and neither while loop is true digitalWrite(ledPin2, LOW);                  // }

Week 8
A third action is being added to the code. This function will just turn the switch off. When the switch is flipped then the motor turns on and rotates to turn the switch off. This function seems basic but has its challenges. One of the challenges was the fact that the count variable had to be changed around so that multiple loops can be added to the code. The count function helps determine what loop is going to occur and keeps all other loops off so that just on loop will occur. A loop is an action that will be taking place. Another Problem encountered was getting the code for the loop in the correct place with the correct count variable. The count Variable goes from 0 to 1 to 2 and then will go back to 0 after the last loop is finished all the way through.