TCPL Robotics Club: Wrestling Robots

120

1

4

Welcome to the Tompkins County Public Library's guide to making Wrestling Robots! The robots made with in this tutorial are used at the TCPL Robotics Club. For more information on the club check out our events page: https://www.tcpl.org/events/tcpl-robotics-club-rob...

The goal of these robots are to give a fun and creative gateway into coding and making. The robots are designed for anyone ages 7+. This guide will be updated as the program grows.

Happy Tinkering!

Supplies:

Step 1: Materials and Tools

Materials:

  • Arduino Uno or Arduino Nano
  • L298N Motor Drive Dual H Bridge
  • HC-05
  • Small Breadboard
  • Breadboard Wire
  • 2x Geared DC Motors with Wheels
  • 9volt Battery Case with a Switch
  • USB adapter for chosen Arduino
  • Re-chargeable 9volt Battery
  • AA battery
  • Ductape
  • Electric Tape
  • Double Sided Tape
  • Hot Glue Stick
  • Cardboard
  • Foam Board

Tools:

  • Hot Glue Gun
  • Hobby Knife
  • Scissors
  • Straight Edge
  • Wire Cutters
  • Small Screwdriver
  • Pen/Marker

Devices:

  • PC/MAC laptop or desktop
  • Android/Kindle Tablet or phone with Bluetooth

Software:














Step 2: Preparing the Chassis

Take a recycled sheet of cardboard. Measure and trace an 8"x 8" inch square. Using scissors or a hobby knife cut out a square. Take three strips of Ductape and adhere them to the left edge, right edge, and center of the cardboard square. Take two strips of Ductape that are the 8" inches long and adhere them to the top and bottom of the cardboard square. Your chassis is complete. All the components of this robot will be taped on. The Ductape on the chassis prevents tearing when you have to remove or fix a component. Your chassis should look similar to the bottom right photo of this step.

Step 3: Wiring the Motors Without Solder

If you are confident with soldering electronics you may skip this step and solder a wire with a breadboard pin to each motor lead. If you would rather not use solder take two breadboard wires with pins at each end. Cut the wires in half and strip each end that do not contain a pin. Twist each of the exposed wire ends and thread them through each motor lead. Gently twist the exposed wire around the motor lead. Once all the wire have been attached to the motors test to make sure they receive electrical current. WARNING! When testing motors do not use 9v battery, it will burn out the motor! Use AA battery instead. If the motor does not rotate when you touch each end of the AA to the wires check to make sure each wire is securely twisted around each lead. Once you are satisfied with the connections its time to secure the wires with hot glue. Apply the hot glue along the back on the motor being careful not glue the motor leads or the center of the motor. The motors we use have a black plastic casing in the back. Place each wire in the glue. Once the glue dries take some electrical tap and tightly wrap around the motor leads and motor.

Step 4: Placing the Components

Cut several strips of double sided tape to the length of your H-Bridge. H-Bridge sizing varies from company to company. If you have an H-Bridge unit with solder connection points sticking out you may want to lightly press a piece of foam/cardboard, cut to size with double sided tape on it, to the bottom of the unit. Tape the unit to the top of the chassis approximately an 1.5"inches from the edge. The H-Bridge unit designates the rear of the chassis. Attach the Arduino Nano to the Breadboard making sure to give at least three row of pin inputs on the side with pins starting with the letter D. Adhere the Arduino and breadboard to the center of the chassis. If you are using the Arduino Uno you will not need a bread board, instead adhere the micro-controller to the center of the chassis. Adhere the 9v battery approximately 3" inches below the Arduino unit. Depending on the 9v battery pack you may have to adjust its location. Both wire coming from the 9v battery pack should be able to plug in to the 12v and GND inputs on the H-bridge. Adhere the two DC motors to the rear of the chassis. Make sure to align the motors with the side edge of the chassis. Make sure both the wires on each motor can be inserted into OUT inputs on the H-bridge. If necessary trim the side of the chassis until the wire reach the inputs.

Step 5: Wiring the Components

You will need the following bread board wires. Note: you do not need to use the same color pattern of wires. If this is you first time assembling a project requiring breadboards and wires we suggest you use the same wire colors to make it easier to follow along!

Wires with a pin on each end:

1x red

1x black

Wires with a pin and an input

1x red

1x black

1x orange

1x yellow

1x white

1x blue

1x purple

1x green

1x grey

1x brown

Note: to attach a wire to an Arduino Nano set in a breadboard insert the pin of the wire next to the desired input. Example, to attach a wire to the GND input insert the wire's pin into a breadboard port next to the GND on the Arduino. To insert a wire into a Arduino Uno without a breadboard insert the wires pin into the desired input. Example, to attach a wire to the GND input insert the wire's pin into the input marked GND.

Attach the black wire with a pin on each end to a GND input on the Arduino. Take the other end of the black wire and the black wire from the 9v battery case and insert them into the GND input on the H-bridge. Tighten the screw on the GND input, do not tighten the input to the point it severs the wires. Take the red wire with pins on both sides and attach one of the pins to VIN on the Arduino. Take the other end of the red wire and the red wire from the 9v battery case and insert them into the 12v input on the H-bridge. Tighten the screw on the 12v input. Take the HC-05 chip and attach the following wires with a pin and an input:

red wire -> 5v

black wire -> GND

orange wire -> TX

yellow wire -> RX

To attach a wire to the HC-05 take the input side of the wire and slide it over the protruding pins of the chip.

Attach the wire connected to the HC-05 to the Arduino

red wire -> 5v

black wire -> GND

orange wire -> D11

yellow wire ->D10

Once the HC-05 is attached to the Arduino adhere it to the chassis between the Arduino and the H-Bridge.

Attach the motor wires to the H-Bridge:

left motor red wire -> OUT2

left motor black wire -> OUT1

right motor red wire -> OUT3

right motor black wire -> OUT4

Attach the Arduino to the H-Bridge. Use the remaining wires with a pin and and an input.

white wire: H-Bridge ENA -> Arduino D3

blue wire: H-Bridge IN1 -> Arduino D2

purple wire: H-Bridge IN2 -> Arduino D4

green wire: H-Bridge IN3 -> Arduino D5

grey wire: H-Bridge IN4 -> Arduino D6

brown wire: H-Bridge ENB -> Arduino D9



Step 6: Upload the Code

Download the free Arduino IDE to your Mac or PC. If you haven't used the Arduino IDE before read this link(the article in this link uses an Arduino UNO if you are using the Nano select Nano instead of the UNO option when uploading code to the Arduino). If you are using an Arduino Nano that is not from the Arduino company you will need to download the driver on this link. Copy the following code into a text editor. Copy the code from the text editor into an Arduino Sketch. Upload code to the Arduino.

#include <SoftwareSerial.h>

#define enA 3                                                                                                                                         
#define in1 2
#define in2 4
#define in3 5
#define in4 6
#define enB 9
#define bluetoothTx 10
#define bluetoothRx 11
int bytes=0;
SoftwareSerial bluetooth(bluetoothRx, bluetoothTx);

void setup() {
  // put your setup code here, to run once:
  void forward();
  void right();
  void left();
  void back();
  void stopped();
  void gear_1();
  void gear_2();
  void gear_3();
  
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);

  bluetooth.begin(9600);
  Serial.begin(9600);
  gear_1();
}

void loop() {
  // put your main code here, to run repeatedly:
 while(bluetooth.available())
  {
    bytes=int(bluetooth.read());
    Serial.println(bytes);

   switch(bytes)
    {
      case 102 :
      {
       forward();
        break;
      }
      case 98 :
      {
        back();
        break;
      }
      case 108 :
      {
        left();
        break;
      }
      case 114 :
      {
        right();
        break;
      }
      case 115 :
      {
        stopped();
        break;
      }
      case 49 :
      {
        gear_1();
        break;
      }
      case 50 :
      {
        gear_2();
        break;
      }
      
      case 51 : 
      {
        gear_3();
        break;
      }
     
      default :
      {
        continue;
        break;
      }
    }
  }
}

void forward()
{
  //right
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  //left
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
}


void right()
{
  //right
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  //left
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
}


void left()
{
  //right
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  //left
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
}


void back()
{
  //right
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  //left
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
}


 void stopped()
{
  //right
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  //left
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}

void gear_1()
{ 
 analogWrite(enA, 120);
 analogWrite(enB, 120);
}

void gear_2()
{
  analogWrite(enA, 170);
  analogWrite(enB, 170);
}

void gear_3()
{
  analogWrite(enA, 250);
  analogWrite(enB, 250);
}

Step 7: Set Up APP and Test Drive

Android App

Kindle App

Open the Bluetooth Electronics App. The app will open to the home screen showing several pre-made control panels. Slide over to an empty panel and select it. Tap on edit and the control panel editor will open up. Along right hand side of the editor you can select different buttons and switches. Select the button option and slide over to find the large buttons. Select and drag out four large green buttons. Place two buttons on the left vertically and two on the right horizontally. Find the buttons with numbers on them and vertically stack them 1, 2, and 3 next to the large green buttons. Select a button and press edit and a text box will appear that will allow you to enter the characters it will send to the robot.

Left side top green button: Press Text f and Release Text s

Left side bottom green button: Press Text b and Release Text s

Right side left green button: Press Text l and Release Text s

Right side right green button: Press Text r and Release Text s

Button 1: Press Text 1 and Release Text 1

Button 2: Press Text 2 and Release Text 2

Button 3: Press Text 3 and Release Text 3

Attach the wheels to your robot and switch it on. Go back to the home screen and select Connect. A new screen will appear select Bluetooth Classic and Next. A screen will appear with available Bluetooth devices select the HC-05/06 and press connect. A text box will appear type 1234 and press done. Once connected you should see the devices name at the top of the screen. On the home screen navigate to the controller you made, select it and press run. Test the robot to make sure the it moves forward when you press the top left button. If it moves backwards or spins note the direction and switch off the robot. Undo the motor and its wires that was rotating in the wrong direction. Attach the wires to the H-bridge opposite to the original connections. For example, if the red wire was in OUT3 and the black wire was in OUT4 put the red one into OUT4 and the black one into OUT3. This is called reversing polarity.

Step 8: Add Armor and Battle!

When you are satisfied with the way your robot drives around its time to armor it up. Take some recycled cardboard and tape it onto the chassis. Happy battling!

Share

    Recommendations

    • IoT Challenge

      IoT Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Party Challenge

      Party Challenge

    4 Discussions

    0
    None
    jeanetteibclc

    Question 15 days ago on Step 5

    Hello Joah! We are having a great time! We hit a road block. Our HC-05 looks a bit different and doesn’t have a 5V input. (See image) Thoughts on next steps? Thank you so much!

    image.jpg
    1 answer
    0
    None
    TCPLjeanetteibclc

    Answer 13 days ago

    Hi jeanetteibclc,
    I'm glad you are all enjoying the build process! My apologies, I forgot they don't always put 5V on the HC-05. Plug the wire for the 5V input into the VCC input.