Knex Cart

Knex Cart

    • ************************************************************************************************************************************************************

Made by Jeremy Mack and Matthew Posh

We programmed an Arduino board to control a servo motor and a normal dc motor to follow a black line on the ground.

Description:

Our Knex Cart follows a black line without veering too much off the black line path. The cart itself has three wheels. The first two wheels are used for propulsion from our power source while the third wheel at the back is used to turn the cart right and left. Our power source is a 9Volt battery and our cart moves forward using a regular dc motor attached to the positive and ground (negative) power from the Arduino board. To turn and change the direction of the cart when the cart is beginning to veer, we use a combination of a servo motor and photoresisters. Depending on how much light the photoresisters register, the photoresisters move the back wheel (which is connected to the servo motor) either left, right, or straight. Both photoresisters are set to register the white floor between the light values of 350 and 650 with the servo motor keeping the wheel straight at 98 degrees. When the servo motor is at 98 degrees the cart goes straight. When the left photoresister registers the light value of 650 or greater (the black line), the photoresister tells the servo motor to turn 11 degrees to the left to correct its path. So, when the servo motor is at 80 degrees the cart turns left. When the right photoresister registers the light value of 350 or lower (the black line), the photoresister tells the servo motor turn 9 degrees to the right to correct its path. So, when the servo motor is at 107 degrees the cart turns right.

Circuitry set-up:

************************************************************************************************************************************

Code:

int potPin = 2; // select the input pin for the potentiometerint val = 0; // variable to store the value coming from the sensor

#include <Servo.h> // accesses the servo library from computer

Servo myservo;

void setup() {

myservo.attach(9); // servo in digital pin 9

Serial.begin (9600);

}

void loop() {

val = analogRead(potPin); // read the value from the sensor Serial.print ("Value = "); // report the text "Value = " Serial.println (val);

if (val>350 && val <650) // light value of white floor

{

myservo.write(98); // angle that allows cart to go straight

delay(1000);

}

if (val<=350) // reads black line from right

{

myservo.write(118); // turn right 9 degrees

delay(1000);

}

if (val >=650) // reads black line from left

{

myservo.write(78); // turn left 11 degrees

delay(1000);

}

}

********************************************************************************************************************************************************************

Problems:

We had multiple problems while making this Knex cart. First of all, the connection to the Knex third wheel and servo needs to be better, stronger, and more workable. Right now we have the servo motor tied to a Knex piece which controls the third wheel movement; right or left. Before, we just have strings attached to the servo and third wheel, but the string would never be taunt nor would it turn back straight. So, we solved that problem by using Knex pieces to attach the the servo and third wheel.

Another problem we had was getting enough power to our cart to move. We found that the connections we had with the wires was loose and our board kept short-circuiting. To solve this issue we simple taped all our connection to secure them tightly.

One more problem we had was that our servo motor was touching the ground causing our cart to slow down to a point where it wouldn't move. So we mounted the servo higher up using more Knex pieces. Now the servo is "floating" in the middle of our cart.

The biggest problem we had was that the photoresisters were too sensitive for our cart. The motor was too fast for the photoresisters to pick up the black line and we needed a constant source of illumination for the photoresisters to even pick up the black line.

Ifs:

If we had more time, we would have wanted to add a transistor to regulate the speed of the motor. Right now, our motor runs at one speed (which is kind of fast) which is able to propel the cart forward. but we wanted it to slow down so the cart can sense the black line better. This was actually our original thought and we tried to do it, but the motor stayed at the same speed. We didn't have the time to research further on how to make the transistor work with our motor, so we just left the idea for another day. Also, if we had the money we would have wanted to find a better base and frame for our cart. One that is more light-weight and could easily turn our cart.