Mario Kart
Make a ballon hoping car
Materials That You Will Need:
· MDF
· Bread boards (3 small ones)
· Relays (2)
· Transistors 2222A (2)
· Arduino UNO (2)
· Gear motor (2)
· Wheels (2)
· Servo Motors (2)
· Styrofoam cutter (2)
· Li-on 5-volt battery
· Bluetooth module (2)
· Arduino Shield Adafruit Motor Shield v2
· Wheels with a 360 movement
· Resistors 1 KΩ (2)
· Jumpers
· Glue any type
Bases
Draw the bases of the car in CorelDraw or any software that lets you cut out the MDF with a laser cutter. You can use any shape you want; we decided to make it round to only use two wheels. And make it two levels to put the weapons on top.
Wheels
Place the wheels into the gear motor as
seen bellow.
Glue the Wheels !
In the bottom part of the MDF structure use any type of glue you like to glue the wheels with the 360 movements.
Columns
Place columns into the MDF structure as seen in the picture bellow. You can use any type of material you want we decided to use those two metal columns.
Gear Motors
Glue the gear motors with the wheels in the MDF bottom structure.
Arduino and Shield
Place the Arduino into the shield. The code use for the Arduino is in the last steps of this document.
Bluetooth
In one breadboard, preferably small make a circuit to connect the bluetooth device. We are using HC-06 Bluetooth devices. In the picture bellow you can see how they were connected. The VCC is connected to voltage, the GND is connected to ground, The RXD is connected to the TXD of the Arduino, and the TXD to the RDX of the Arduino.
Battery
Use the li-on battery to energize the Arduino and the shield with different inputs. And place the battery in the MDF bottom structure.
Connections
Connect the gear motor into the shield, we are using the M1 and M2, but you may use the other. Just note that if you change them you need to modify the code bellow.
MDF Structures
Place the MDF top structure in top of the bottom structures and fix it using screws.
Construction
Using a construction set mecano we built a structure like the one seen in the image bellow.
Styrofoam Cutter
Open up the Styrofoam cutter, and cut out the push button and weld two wires one where the LED is placed and the other where the battery is placed. The mage below shows how it should look.
Relay
Using another breadboard connect the relay with a resistor and the transistor as seen bellow. The orange jumper will be connected to the Arduino to turn on and off the Styrofoam cutters as needed.
Servo Motor
Glue the servo motor to the structure that was made in step 11. Then glue the servo motor to the MDF structure.
Styrofoam Cutter
The Styrofoam cutter is then fixed to the structure used in step 14.
Steps 11, 12, 13, 14 and 15 are done twice since we made the car with two exact weapons.
Same Procedure
Repeat step seven, to have another breadboard with the Bluetooth module.
Control
Connect the servos, one cable to voltage the other to ground. The control wire is connected directly to the Arduino that will be placed on top.
Arduino Battery
Place a battery in the top part so that this battery energizes the Arduino and the servomotors.
Codes
Copy and paste the codes into your Arduino software. The codes that we used for the cart are can be seen here bellow.
Code for
gear motors
//include files to add other files or libraries to the current program
#include
#include
#include
int estado = 0 ; //creates a variable that will be used to test the conditions.
SoftwareSerial blue(10 , 11); // RX, TX setting up pins for Bluetooth Communication
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); // Create the motor shield object with the default I2C address
Adafruit_DCMotor *myMotor = AFMS.getMotor(1); //Selecting Port to attach a motor. motor one goes to port 1
Adafruit_DCMotor *myMotor2 = AFMS.getMotor(2); //Selecting Port to attach a motor. motor one goes to port 2
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
blue.begin(9600); // sets the baud rate at 9600 bps
blue.println("is bluetooth working?"); //prints a line to test if bluetooth is working
AFMS.begin(); // setup Serial library at 9600 bps
}
void loop()
{
if(blue.available()>0){ //this is used to read the values by the HC-0X bluetooth module
estado = blue.read(); //the variable declared now changes its value to what it was received by the bluetooth module
}
//all these if's are used to perform certain actions. for example: in the first if, the stop command is implemented by stopping all the motors.
//stop setting all the motors to a speed of 0
if (estado =='s'){
myMotor->run(RELEASE); //motor one is set to stop
myMotor->setSpeed(0); //motor one is set to speed 0
myMotor2->run(RELEASE); //motor two is set to stop
myMotor2->setSpeed(0); //motor two is set to speed 0
}
//forward setting one motor to run forward while the other is running backward
if (estado =='w'){
myMotor->run(FORWARD); //motor one is set to run forward
myMotor->setSpeed(255); //motor one is set to max speed. 255 is the highest possible value, whereas 0 is the lowest.
myMotor2->run(BACKWARD); //motor two is set to run backward.
myMotor2->setSpeed(255); //motor two is set to max speed. 255 is the highest possible value, whereas 0 is the lowest.
}
//backwards it is the same code as forward; the only change is that motor one is now running backward and motor2 is running forward.
if (estado =='x'){
myMotor->run(BACKWARD); //motor one is set to run backward
myMotor->setSpeed(255); //motor one is set to max speed. 255 is the highest possible value, whereas 0 is the lowest.
myMotor2->run(FORWARD); //motor two is set to run forward
myMotor2->setSpeed(255); //motor two is set to max speed. 255 is the highest possible value, whereas 0 is the lowest.
}
//turn left this time, both motors run to the same direction
if (estado =='a'){
myMotor->run(FORWARD); //motor one is set to run forward
myMotor->setSpeed(255); //motor one is set to max speed. 255 is the highest possible value, whereas 0 is the lowest.
myMotor2->run(FORWARD); //motor two is set to run forward
myMotor2->setSpeed(255); //motor two is set to max speed. 255 is the highest possible value, whereas 0 is the lowest.
}
//turn right the motors will run to the same direction, but opposite to turn left
if (estado =='d'){
myMotor2->run(BACKWARD); //motor two is set to run backward
myMotor2->setSpeed(255); //motor two is set to max speed. 255 is the highest possible value, whereas 0 is the lowest.
myMotor->run(BACKWARD); //motor one is set to run backward
myMotor->setSpeed(255); //motor one is set to max speed. 255 is the highest possible value, whereas 0 is the lowest.
}
//slow left turn the motors will turn left slowly. it is the same code as for turn left, but with slower speed
if (estado =='q'){
myMotor2->run(FORWARD); //motor two is set to run forward
myMotor2->setSpeed(100); //motor two is set to 40% of max speed. 255 is the highest possible value, whereas 0 is the lowest.
myMotor->run(FORWARD); //motor one is set to run forward
myMotor->setSpeed(100); //motor one is set to 40% of max speed. 255 is the highest possible value, whereas 0 is the lowest.
}
//slow right turn the motors will turn right slowly. it is the same code as for turn right, but with slower speed
if (estado =='e'){
myMotor->run(BACKWARD); //motor one is set to run backward
myMotor->setSpeed(100); //motor one is set to 40% of max speed is the highest possible value, whereas 0 is the lowest.
myMotor2->run(BACKWARD); //motor two is set to run backward
myMotor2->setSpeed(100); //motor two is set to 40% of max speed. 255 is the highest possible value, whereas 0 is the lowest.
}
}
Code for servo motors (Styrofoam cutters)
//include files to add other files or libraries to the current program
#include
#include
Servo miServo; //declares a servo
Servo miServo2; //declares a servo
int estado = 0; //creates a variable that will be used to test the conditions.
SoftwareSerial blue(10, 11); // RX, TX setting up pins for Bluetooth Communication
void setup() {
blue.begin(9600); // set up Serial library at 9600 bps
blue.println("iniciar bluetooth"); // sets the baud rate at 9600 bps
miServo.attach (3); //attach the servo 1 to pin 3
miServo2.attach (5); //attach the servo 2 to pin 5
}
void loop() {
if (blue.available() > 0) //this is used to read the values by the HC-0X bluetooth module
{
estado = blue.read(); //the variable declared now changes its value to what it was received by the bluetooth module
pinMode(7, OUTPUT); //used to turn the first weapon on. this weapon consisted of a styrofoam (Expandable Polystyrene) cutter that enables the car to burn the ballons at contact.
pinMode(4, OUTPUT); //used to turn the second weapon on.
}
//all these if's are used to perform certain actions. for example: in the first if, the servo
if (estado == 'a') {
miServo.write(70); //the servo is moved to this position
digitalWrite (7, LOW); //the weapon attached to the servo is activated.
}
if (estado == 's') {
miServo.write(120); //the servo is moved to this position
digitalWrite (7, HIGH); //the weapon attached to the servo is activated.
}
if (estado == 'k') {
miServo2.write(30); //the servo is moved to this position
digitalWrite (4, HIGH); //the weapon attached to the servo is activated.
}
if (estado == 'g') {
miServo2.write(100); //the servo is moved to this position
digitalWrite (4, LOW); //the weapon attached to the servo is activated.
}
}