Saturday, December 13, 2014

Highlighted in red shows the changes that we made to the code.  The changes helped to allow the catapult to shoot completely before returning back to its original position.  Before this change, if the button was let go before the arm was finished shooting it would stop in the middle of its path and go back.  This change will avoid this from happening and make the prototype much more user friendly.  We were unable to get the part 3D printed for the catapult arm due to it being a part that was not compatible or able to be 3D printed for some reason.  The pieces for the box should have been laser cut to create a much more exact prototype.  The design was an overall success and we are happy with the final result.  The project could have been improved by the use of a motor instead of the servo since the motor would have given the "ammo" a much higher velocity and worked better.
Arduino Code
Parts Files

#include <Servo.h> 
const int buttonPin = 5;
const int ledPin1 = 2;
const int ledPin2 = 3;
const int ledPin3 = 4; 
Servo myservo; 
int pos = 0;
int buttonState = 0;

void setup() 
{ 
  myservo.attach(9);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);
} 
void loop() 
{ 
  buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {     
    delay (15);
    digitalWrite(ledPin1, HIGH);
    delay (500);
    digitalWrite(ledPin2, HIGH);
    delay (500);
    digitalWrite(ledPin3, HIGH);
    delay (500);
    myservo.write(120);
    delay (250);   
  } 
  else {
    delay (250);
    digitalWrite(ledPin1, LOW); 
   digitalWrite(ledPin2, LOW);
   digitalWrite(ledPin3, LOW);
  delay (100);
    myservo.write(0);
    delay (15);
  }
}

Wednesday, December 10, 2014

      This is our final prototype.  The servo is taped into the cardboardbox and then glued to the catapult arm.  The arm itself is supposed to be made of 3D printed plastic material but there have been a lot of delays in getting this part fabricated, so this is our prototype as it stands.  The code involves using a button to control the firing of the catapult.  When the button is held down, a succesion of 3 LEDs are lit to act as a countdown.  The servo is then told to run and the arm goes about 120 degrees.  When the button is let go, the LEDs and the servo return to their normal states and wait for the button to be pressed again.

Here is the code used for the arduino.

#include <Servo.h> 
const int buttonPin = 5;
const int ledPin1 = 2;
const int ledPin2 = 3;
const int ledPin3 = 4; 
Servo myservo; 
int pos = 0;
int buttonState = 0;

void setup() 
{ 
  myservo.attach(9);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);
} 
void loop() 
{ 
  buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {     
    delay (15);
    digitalWrite(ledPin1, HIGH);
    delay (500);
    digitalWrite(ledPin2, HIGH);
    delay (500);
    digitalWrite(ledPin3, HIGH);
    delay (500);
    myservo.write(120);
    delay (1);   
  } 
  else {
    delay (5);
    digitalWrite(ledPin1, LOW); 
   digitalWrite(ledPin2, LOW);
   digitalWrite(ledPin3, LOW);
  delay (100);
    myservo.write(0);
    delay (15);
  }
}

Here is a working prototype of our project:

Tuesday, December 9, 2014

Prototyping

      Today we worked on creating a physical model of the project.  Reusing a decorative Louis Vuitton box we cut and glued various pieces into the boxes we needed.  The motor sits nicely on the shelf in the middle of the assembly.  It will be held down using tape so that it does not spin around or fall off of its mount.  The arm itself is a prototype made of the same cardboard, we are planning on using one that is 3D printed if time will allow.  One box on the arm is bigger than the other because this is the one used for "throwing" so it has a small cavity for placing the ammo.