Everyone was at our group meeting this week. The meeting lasted around 3 hours.
/*note: The servo tends to vibrate when at the extreme positions of 0 and 180 degrees*/ #include<Wire.h> //motor libraries #include <Adafruit_MotorShield.h> #include "utility/Adafruit_PWMServoDriver.h" #include<Servo.h> //servo library Servo serv; //defines "serv" object Adafruit_MotorShield motor = Adafruit_MotorShield(); //defines motor object int servpin=9; //defines servo pin int buttonpin=2; //defines button pin Adafruit_DCMotor *myMotor = motor.getMotor(1); //attaches motor to motor pins 1 int gate_seconds=5; //defines the gate delay int gate_mseconds=gate_seconds*1000; int drop_seconds=2; //defines the drop delay int drop_mseconds=drop_seconds*1000; int lift_seconds=4; //defines the lift delay int lift_mseconds=lift_seconds*1000; void setup() { motor.begin(); serv.attach(servpin); //attaches serv to servpin pinMode(buttonpin,INPUT_PULLUP); //initializes button pin } void loop() { myMotor->run(RELEASE); //sets motor to initially be still serv.write(33); //states the initial position of the servo int button=digitalRead(buttonpin); //defines the button input variable if (button==LOW) { serv.write(160); //opens the gate delay(gate_mseconds); //holds the gate open serv.write(33); //closes the gate myMotor->setSpeed(150); //drops weight myMotor->run(FORWARD); delay(drop_mseconds); myMotor->setSpeed(150); //lifts weight myMotor->run(BACKWARD); delay(lift_mseconds); myMotor->run(RELEASE); //holds weight stationary } }
This is an updated code for our nutcracker. We needed to update our code because we needed to use a shield in order for our motor to work. The motor did not work because it requires 12 volts. We burnt out our arduinos and had to replace them by borrowing one from Daniel Sullivan. We also borrowed the shield from him.
We acquired a dumbbell and cut it into an appropriate shape for our nutcracker. We cut the dumbbell with a hacksaw. The dumbbell was too wide so we cut off one of the ends of the dumbbell and cut off a portion of the other end.
This video is a motion study
No comments:
Post a Comment