Self-driving Toycar: Difference between revisions

From Hackers & Designers
Line 53: Line 53:
[[File:UNADJUSTEDNONRAW_thumb_15dd.jpg|500px|sensor]]
[[File:UNADJUSTEDNONRAW_thumb_15dd.jpg|500px|sensor]]
[[File:UNADJUSTEDNONRAW_thumb_15e0.jpg|500px|sensor]]
[[File:UNADJUSTEDNONRAW_thumb_15e0.jpg|500px|sensor]]
[[File:UNADJUSTEDNONRAW_thumb_15e1.jpg|500px|sensor testing]]


=== Sensor testing ===
=== Sensor testing ===

Revision as of 11:33, 28 February 2017

self driving toycar

Workshop manual

Team up!

  • Form teams of 3-4 people
  • Give your team a name!

Deconstuct the car

  • Remove the screws on the bottom and remove the top.
  • Cut of all the wires going to the BCP, as close as possible to the PCB. (make sure the power switch keeps working and that it is off)

strip

Connect the Motor driver

  • IMPORTANT! disconnect the (green) jumper marked PWR right next to the screw terminal marked EXT_PWR
  • Connect the shield to the Arduino
  • Connect motor shield and Arduino to the car: Make sure motor, steering and battery cables are connected to the right outputs of the shield

connect connect

  • Cover the bottom of the Arduino with a piece of tape to prevent a connection of arduino with the battery (short circuit)
  • Put the AA batteries in the car
  • Connect 9 v battery to arduino, then connect the battery to the motor shield

battery

Motors test over serial connection

  • Connect Arduino to your computer

connect

  • Install Arduino Software
  • Test with sample code
  • After downloading the zip file from Github open SDC_motor_test.ino
  • In Arduino go to "Menu" > "Sketch" > "Include library" > "Manage libraries" > search for "Adafruit Motor shield V1 firmware" and add
  • Test with Serial Monitor. Change cables if necessary.

Connect the line sensor

  • Take 3 cables, put it on the sensor, look carefully at the colours and connections (A0, GND, VCC)
  • Connect to the Arduino/Motorshield to the sensor
Module  ->    Arduino   
- - - - - - - - - - -
VCC     ->    5V
GND     ->    GND
A0      ->    A0


  • Connect the line sensor analogue output to A0.

GND -> GND VCC -> 5V


sensor sensor sensor testing

Sensor testing

  • Test line sensor with: SDC_TCRT5000.ino
  • Follow instructions in the file to find out the lowest and the highest values to distinct the line from the floor.

sensor testing sensor testing

Upload the car software

  • Open and upload SDC_complete.ino
  • Adjust the values
  • Upload the sofware to the Arduino

Enhance the software

  • Test on the line and adjust values of speed or sensor if nessessary

Tipps

  • It can help to remove the V9 battery when you upload the program to the arduino
  • Make sure your sensor is close to the ground


Ideas:

  • Add ultrasonic sensor to avoid collisions
  • The car now always steers either left or right. Can we add straight ahead?
  • Try to make the steering proportional to the error in the line sensor
  • Make the light sensor trainable. (Maybe add a button to switch between training / driving mode?)


Notes

  • We need spare batteries!

External links


Used modules:

Stuff that might need explaining?

  • What is an h-bridge?