Yet Another Line Following / Obstacle Avoidance 2WD Car

11,067

38

14

Introduction: Yet Another Line Following / Obstacle Avoidance 2WD Car

About: My goal is to captivate, inspire and engage young engineers through intriguing robotics projects. I use Arduino at my robotics workshops since it is the most cost-effective way to build a robot using commodit…

This robot car is nothing new. Instructables and Youtube are peppered with a robot car similar to this one and honestly those postings inspired me to put together this affordable robotics kit that I could handout at my Robotics workshop (level 1) for grades 6-12. As far as what it does, the title says it all (or see the video) so I won’t bore you with details. This robot isn’t going to win any competitions or awards for being best of _whatever_ but it is an affordable kit which is perfect for educational purposes.

(Update: I made a line-following billboard bot with this platform)

Step 1: Parts

This is a standard kit for my Robotics workshop (Level 1) and you can find parts on-line (except bumper). However, if you like to support my mission* of teaching youth Robotics, you may be able to order the same kit in the future. (*I only assess materials fee for the workshop.)

The kit contains:

  • 2WD car chassis w/ 2 motors, caster, and 6v battery holder (added extra holes for custom mods)
  • custom-made bumper to attach sensors (I couldn't find anyone selling this so I made it out of corner protector you can buy at Home Depot)
  • 9V battery holder
  • Arduino Uno compatible board
  • Motor shield
  • Ultrasonic sensor
  • 2 x infrared sensor
  • Mini breadboard
  • 20 x wire tie
  • 8 x 1in square foam tape
  • 20 x MF 20cm Dupont connector
  • 10 x MM 20cm Dupont connector
  • USB to mini USB cable
  • 4 x AA battery
  • 1 x 9v battery
  • Velcro strap for 6v battery holder (batteries pop out from time to time)
  • Additional flathead M3 7mm and 10mm screws for the bumper and the 9v battery holder.
  • Precision screwdriver set

While motor connectors are pre-soldered with Dupont connectors, soldering is still required for the switch. The plan for the next release is to have all Dupont connections. No soldering! Also, all the flathead screw holes have been counter-sink.

Step 2: Assemble the Car

See the presentation below for assembling the car.

Part 1: Chassis, Motor, Motor Shield, and Arduino (or compatible) board

https://docs.google.com/presentation/d/14f_G5VRUoQ...

Part 2: Sensors

https://docs.google.com/presentation/d/1AxMY8jMx56...

Step 3: Compile and Upload

Download following codes into your Arduino IDE, compile, and upload based on your scenario.

1) Obstacle Avoidance Bot

https://drive.google.com/file/d/0B2KyCJ0WKOzSRURKV...

2) Line Following Bot

https://drive.google.com/file/d/0B2KyCJ0WKOzSbFR2Q...

Step 4: Run

If you have followed my wire connections and pin assignment, the 2 codes for obstacle avoidance and line follower should run out of box. Through my Robotics workshop, my aim is to inspire younger generations to love science and engineering by making something with their hand and learn from doing it...rather than just playing games on smartphones.

If you enjoyed my tutorial and video, please vote for this Instructables for the "Full Spectrum Laser" contest. The laser-cutter would allow me and the kids to fabricate additional parts for future workshops - robot laser tag, self balacing bot, drone, etc.

Full Spectrum Laser Contest 2016

Participated in the
Full Spectrum Laser Contest 2016

Be the First to Share

    Recommendations

    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    14 Discussions

    0
    Kyle WinstonC
    Kyle WinstonC

    Question 1 year ago on Step 3

    Hi im using an arduino uno, i have also checked both codes. What should i do if I want my robot to stop when there is an obstacle while following a line? thanks

    0
    botdemy
    botdemy

    Answer 1 year ago

    Basically you have to have ultrasonic sensor check supersedes line following:

    pseudocode:

    if ultrasensor value < some distance (maybe 10cm) {
    stop;
    }
    else {
    line following code here
    }

    0
    정웅김
    정웅김

    2 years ago

    This project is Great for me!

    but I want to make a obstacle avoiding and line following car.
    how to combine and use three sensors value.

    0
    정웅김
    정웅김

    Question 2 years ago on Step 4

    This project is Great for me!

    but I want to make a obstacle avoiding and line following car.
    how to combine and use three sensors value.

    0
    16119088
    16119088

    3 years ago

    mình thay bằng mạch cầu H L298N được không

    0
    AnaV50
    AnaV50

    3 years ago

    Can i use adafruit motor shield instead of your motor shield and how that changes the code?

    0
    botdemy
    botdemy

    Reply 3 years ago

    I'm not sure what type of Adafruit motor shields you have but I believe adafruit has a good tutorial on how to use their products. Adafruit may even have a library so you could use the library and their functions in your code.

    Basically you have 6 pins to control: left +, left -, left pwm/ena, right +, right -, and right pwm/ena. If you're not going to use PWM, set PWM/ENA pins to always high. (Mine came with jumpers to set them always high). If you do that, you now have 4 pins to control - 2 for each motors. Just play with the code until it works. That's the best way to learn.

    0
    AnaV50
    AnaV50

    Reply 3 years ago

    Thanks

    0
    TharindaSL
    TharindaSL

    4 years ago

    can you please tell me how to combined these two coads?

    0
    botdemy
    botdemy

    Reply 4 years ago

    You will have to figure out on your own. That shouldn't be too difficult. Basically, your main loop has to check 3 sensors (2 IR and 1 Ultransonic) for their values and decide what you want to do. For example, below is another version I have worked on. It checks for all 3 sensors.

    0
    bcornu
    bcornu

    4 years ago

    Hello, thank you for the tuto.

    I would like to make the line follower, but it doesn't work and i try to know why.
    I use a L293D motor Driver expansion instead of your motor shield. How that changes the code ?

    Thanks for the help

    0
    botdemy
    botdemy

    Reply 4 years ago

    I am not sure but for two wheel configuration, you just need to control 6 input - 2 for motor and one pwm per wheel.

    0
    wold630
    wold630

    4 years ago

    This is great! What would you estimate the total cost to be to build it?

    0
    botdemy
    botdemy

    Reply 4 years ago

    I buy 10 pcs at a time and total cost of each comes out less than $40 including the plastic container. If you're buying for just one, the cost would be slightly higher.