/*note: The servo tends to vibrate when at the extreme positions of 0 and 180 degrees*/ #include<Servo.h> Servo serv; //defines "serv" object int gate_seconds=5; //defines the gate delay variable int gate_mseconds=gate_seconds*1000; int drop_seconds=2; //defines the drop delay variable int drop_mseconds=drop_seconds*1000; int servpin=3; //defines servo pin int motormain=11; //defines motor pins int motor1=9; int motor2=5; int buttonpin=2; //defines button pin void setup() { serv.attach(servpin); //attaches servo to servpin pinMode(buttonpin,INPUT_PULLUP); //initializes button pin pinMode(motormain,OUTPUT); //initializes motor pins pinMode(motor1,OUTPUT); pinMode(motor2,OUTPUT); } void loop() { digitalWrite(motormain,LOW); //holds the weight stationary digitalWrite(motor1,LOW); digitalWrite(motor2,LOW); serv.write(3); //states the initial position of the servo int button=digitalRead(buttonpin); //defines the button input variable if (button==LOW) { serv.write(176); //opens the gate delay(gate_mseconds); //holds the gate open serv.write(3); //closes the gate digitalWrite(motormain,HIGH); //drops the weight digitalWrite(motor1,HIGH); digitalWrite(motor2,LOW); delay(drop_mseconds); digitalWrite(motormain,HIGH); //lifts the weight digitalWrite(motor1,LOW); digitalWrite(motor2,HIGH); delay(2*drop_mseconds); digitalWrite(motormain,LOW); //holds the weight stationary digitalWrite(motor1,LOW); digitalWrite(motor2,LOW); } }
This is a incomplete draft of our code to run the servo and the motor.
SIDE
FRONT
TOP
These are pictures of our nutcracker. The nutcracker has more parts that need to be attached. This is the overall structure of the nutcracker. These blue parts make up the structure of the nutcracker.
This is a revised version of the base plate. The base plate was revised because the laser cutter could not cut part ways through the material.This is a revised version of the front bracket. The new version of the front bracket replaced the rear bracket in the old assembly, so now we are using 2 front brackets. The front bracket was revised to add the jigsaw effect to make it easier to assemble.
This is the same motor part from the previous version.
These two parts are a separate revised assembly for the servo. The revised version is a more detailed representation of our servo.
This is a revised version of our side shield. The side shield was revised to fit the front brackets jigsaw effect to make it easier to assemble.
No comments:
Post a Comment