Color Sensing Robot

by kalo4tf in Circuits > Arduino

33 Views, 1 Favorites, 0 Comments

Color Sensing Robot

20241204_104817.jpg

This instructable will show you how to build a robotic car that draws a certain shape based off of the color it senses. We used the Sparkfun tool kit box as the body, and the majority of the parts of the car are from the Sparkfun tool kit except for the color sensor. We tried to make the building part as easy as possible because understanding the code is somewhat difficult, but everything is very doable. Enjoy!

Supplies

IMG_0064.jpeg

You will need the SparkFun inventors kit v4.1

All supplies needed:

  1. 1 Arduino Uno
  2. 1 Small Breadboard
  3. 1 Motor Driver
  4. 1 Medium Cardboard Box/ SparkFun Box
  5. 1 Marker
  6. 1 Servo Motor
  7. 1 large sheet of paper
  8. 2 Hobby Gearmotors
  9. 2 Wheels
  10. 1 Battery Pack
  11. 4 AA Batteries
  12. 22 Wires
  13. 5 zipties

Create TinkerCAD Circuit and Code

Screenshot 2024-12-10 at 9.10.16 PM.png
  1. Create the wiring on the TinkerCAD website and wire the board to look like the photo above.
  2. Write the code as it follows in the attachment below.

The video below explains how the code works.

Code Explainer Video.mp4

Downloads

Wiring

Screenshot 2024-12-10 at 9.51.33 PM.png
Screenshot 2024-12-10 at 9.53.25 PM.png

Tools needed

  1. Breadboard
  2. Arduino Uno
  3. Motor Driver
  4. 4 wires

First, we need to form a connection from the breadboard to the Arduino Uno

  1. Positive supplies power, connect to 5v
  2. Negative connects to ground (GND)
  3. Then connect the positive on one side of the breadboard to the other side
  4. Do the same with the negative
  5. Add the motor driver to the Breadboard as shown
  6. Connect PWMA to 11 on the Arduino Uno using a wire
  7. Connect AIN2 to 12 on the Arduino Uno
  8. Connect AIN1 to 13 on the Arduino Uno
  9. Connect BIN1 to 10 on the Arduino Uno
  10. Connect BIN2 to 9 on the Arduino Uno
  11. Connect PWMB to 10 on the Arduino Uno
  12. Using a red wire connect STBY to positive on the breadboard
  13. Using a black wire GND to negative on the breadboard
  14. Connect VM to VIN on the Arduino Uno
  15. Connect VCC to positive on the breadboard
  16. And finally connect both of the GND on the top of the motor driver to negative on the breadboard
  17. Connect the red wire of the first Hobby Gearmotor to A01 on the motor driver
  18. Connect the black wire of the first Hobby Gearmotor to A02 on the motor driver
  19. Connect the red wire of the second Hobby Gearmotor to B01 on the motor driver
  20. Connect the red wire of the second Hobby Gearmotor to B02 on the motor driver

Servo Motor

  1. Connect the left pin (Ground) on the Servo Motor to negative on the Breadboard using a black wire
  2. Connect the middle pin (Power) on the Servo Motor to positive on the Breadboard using a red wire
  3. Connect the right pin (Signal) on the Servo Motor to A0 on the Arduino Uno using a colored wire

Color Sensor

  1. The color sensor has 6 pins but for this project we are only using the inner 4
  2. First connect the GND pin to GND on the Arduino Uno
  3. Then connect the VCC pin to 3.3V on the Arduino Uno
  4. Next connect the SDA pin to A4 on the Arduino Uno
  5. Finally connect the SCL pin to A5 on the Arduino Uno


Full wiring video below

l l l l l

v v v v v

Wiring Video.mp4

Create Chassis

IMG_0066.jpeg
IMG_0065.jpeg
IMG_0067.jpeg
  1. Make sure Sparkfun kit box is empty and open. And cut a rectangular piece from the front of the box like it's shown in the photo under the Introduction.
  2. Make two horizontal slits on both short ends of the box. One towards the top and one towards the bottom and make sure the slits are directly across from each other as these will be used to tie the two Hobby Gearmotors to each side of the box. Cut small holes on both of these sides small enough to slide the wiring for each gearmotor through.
  3. Also make two horizontal slits in the top and bottom of the center of the front part of the box, and cut a rectangular side hole between the two slits that way the gear motor can slide in from the inside of the box.
  4. Cut another rectangular hole in the center of the top of the box big enough to slide the color sensor in place as well as the wiring for it.
  5. To add a fun element, use the rectangular cut out from part 1 as a spoiler for this car by taping it to the back of the box.

The video below describes the cuts in the chassis and the wiring.

VID_20240411_093640.mp4

Put Everything Together

Dont use.jpeg
  1. Unplug the wiring for the gearmotors, the servo motor and the color sensor and place everything else inside the box inclusing the battery pack
  2. Thread the wiring for the two gearmotors through the small holes you made on each side of the box. Then use a zip tie to attach the gearmotors to each side of the box by threading it through the two slits you made on either side.
  3. Thread the wiring for the color sensor through the hole you made on the top of the box and secure the color sensor to the top of the box.
  4. Slide the servo motor and its wiring through the hole you made on the front part of the box and use the two slits you made two secure it in place with a zip tie. Also zip tie the marker to the
  5. Reconnect all the wires back to the board, then close the box.

Watch the video below to see how to put everything together.

Putting Together.mp4

GO TIME!!

  1. Get a piece of paper at least 4x4 ft and place it on the ground securing it on each corner.
  2. Make sure the battery pack is plugged in and the code is uploaded to the robot through Arduino, then place it in the center of the paper.
  3. Use your phone and get a blue, green and red picture.
  4. Place the phone with either of the photos over the color sensor and let the robot do its thing!

Below are 3 videos showing the robot creating the triangle, square and circle without the marker.