Thursday, December 12, 2013

Final Project Post

We have successfully completed the building of our tow truck. We just wrapped up the assembly and final testing before the presentation on Friday. We are very excited that our project works as planned with minimal adjustments, and that it picks up and moves small objects into our designated drop bin.

The following are pictures of the final assembly and projects as well as a video of what Mater does.

The final Arduino code for the motion is also posted.

Here is the final Gist:
/*
Mater the Tow Truck Arduino Project
Fianl sketch
Purpose of Project: To control three servo motors using two potentiometers and a push button
to provide rotation and movement to the members of our
tow truck crane arm.
*/
#include <Servo.h> // include servo library
Servo Paul; // create servo object to control a servo and to name each servo
Servo Chris; // create servo object to control a servo and to name each servo
int potpin = A0; //analog pin used to connect the potentiometer
int potValue; //variable to read the value from the analog pin
int potpin2 = A1; //analog pin used to connect the potentiometer
int potValue2; //variable to read the value from the analog pin
int button1 = 9; //button pin, connect to ground to move servo
int press1 = 0;
Servo servoWinch; // create servo object to control a servo and to name each servo
void setup()
{
Chris.attach(8); //attatch Servo Chris to pin 8
Paul.attach(10); //attatch Servo Paul to pin 12
Serial.begin(9600); //begin serial communication to serial monitor
pinMode(button1, INPUT); //Set the pin for button1 as an Input state
servoWinch.attach(7); //Attatch the winch servo to pin 7
digitalWrite(9, HIGH); //enable pullups to make pin high
}
void loop()
{
potValue = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
potValue = map(potValue, 0, 1023, 20, 150); // scale it to use it with the servo (value between 20 and 150)
Paul.write(potValue); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
Serial.println(potValue); // displays potentiometer value to serial monitor
potValue2 = analogRead(potpin2); // reads the value of the potentiometer (value between 0 and 1023)
potValue2 = map(potValue2, 0, 1023, 20 , 150); // scale it to use it with the servo (value between 20 and 150)
Chris.write(potValue2); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
Serial.println(potValue2); // displays potentiometer value to serial monitor
press1 = digitalRead(button1); // If button is pressed, Arduino reads the button state
if (press1 == LOW) // If button state is Low, moves servo position to 17 degrees
{
servoWinch.write(170);
}
else {
servoWinch.write(15); // If button state is high, servo position will move to 15 degrees
}
}
view raw gistfile1.txt hosted with ❤ by GitHub
Our final assembly consists of three servo motors, two controlled by potentiometers and one controlled by a push button. The two potentiometers control the rotation of the whole assembly, and the push button controls the winch. The parts we used consisted of two laser cut pieces that we designed and had fabricated for the assembly. These include the truck bed cover, and the circular mount. We also designed two 3D printed servo brackets to hold down the servos that are mounted on the circular mount. We used a 15 hole Lego beam for our tow arm. A string and paper clip was also used to construct the hook attached to the winch. The Arduino board is mounted to the top of the truck. Overall, we feel that this project was a great success. We stuck with our original idea of turning a regular toy truck into a tow truck, and made it a reality. We feel that this project works really well for what we have. It does exactly what it was designed to; allow the user to utilize the remote control to pick up and move small objects easily. The only issue we ran into when building our project, was that the tolerance was off very little on some of the manufactured pieces, but was nothing a little filing could not fix to make it work. If we were to add one more thing, it could be a groove for the winch cable to ride on, but it is not necessary. Overall, the project was a success and we are happy with it.

No comments:

Post a Comment