Zelfrijdende auto

From Hackers & Designers
MainNavigation No

self driving toycar

Workshop manual

Form groepjes!

  • Form groepjes van 3-4

Haal de auto uit elkaar

  • Verwijder alle schroeven en verwijder de buitenkant van de auto.
  • Snijd alle kabels van de PCB af. Let op: Snijd zo dicht bij de PCB als mogelijk. Controleer of de power schakelaar nog werkt en uitgeschakeld staat.

strip


Test de Arduino en de Arduino software

Installeer Arduino Software

Arduino

Open je eerste Arduino sketch

Open de LED blink voorbeeld sketch: File > Examples >01.Basics > Blink.

Open sketch

Selecteer je board type en port

Selecteer de ingang die bij je Arduino board past.

Select board

Selecteer de "serial device" van he board via Tools | Serial Port menu. Om te weten welke port je moet gebruiken kun je de board ontkoppelen en het menu opnieuw openen; de ingang die zou moeten verschijnen is Arduino or Genuino board. Verbind je Arduino opnieuw en selecteer deze ingang.

Select COM port


Upload het programma

Nu click gewoon de "Upload" button. Wacht een aantal secondes. Je zou de RX en TX leds op het board zien blinken. Indien de upload successvol was zie he het bericht: "Done uploading." in de status bar.


Upload sketch

Na een aantal secondes zou je de pin 13 (L) LED op het board moeten zien blinken (in oranje). Als dit het geval is: Gefeliciteerd! Je Arduino is klaar voor de volgende stappen!


Verbind de Motor Driver

De Motor Driver of Arduino Motor Shield maakt het mogelijk om de motor richting en tempo met een Arduino te controleren.

Motor shield

  • Belangrijk! Verwijder de (groene) etikett gemarkeerd met PWR, naast de schroef terminal gemarkeerd met EXT_PWR
  • Verbind het shield met de Arduino
  • Verbind motor shield en Arduino met de auto: Let op dat motor, stuur en batterij kabels cables verbonden zijn met de juiste uitgangen van het shield.

Connect the motors

Steering motor       -> Shield M1
Driving motor        -> Shield M4
Car battery wires    -> Shield EXT_PWR
  • Plak een stuk tape op de onderkant van de Arduino om een kortsluiting te verkomen
  • Leg AA batterijen in de auto
  • Verbind 9 v batterij met Arduino, verbind dan de batterij met het motor shield

battery


Motor test via serial verbinding

  • Verbind Arduino met je computer

connect

  • Er is voorbeld code voor deze workshop die je op Github kunt downloaden: sample code
  • Na de download van het zip bestand open SDC_1_motor_test.ino
  • In Arduino ga naar "Menu" > "Sketch" > "Include library" > "Manage libraries" > en zoek naar "Adafruit Motor shield V1 firmware" en voeg toe add
  • Test of het Motor Shield het doet door de Serial Monitor te openen (loep boven rechts)
  • Test of de richting van het stuur werkt zoals verwacht
  • Verander de kabels op het Motor Shield indien nodig

Connect the line sensor

The line detection sensor module sends out short pulses of (invisible) infrared light and measures how much of that light comes back. It output the brightness/darkness as an analog voltage that the Arduino can use to steer the car.

line sensor

  • Take 3 cables, put it on the sensor, look carefully at the colours and connections (A0, GND, VCC). The motor shield has connections for the analog pins on the Arduino conveniently grouped with GND and 5V pins. We use these to connect our sensor to. A0 is the pin right next to the pin marked 9V.
  • Connect to the Arduino/Motorshield to the sensor
Module  ->    Arduino   
- - - - - - - - - - -
VCC     ->    5V
GND     ->    GND
A0      ->    A0
  • Connect the line sensor analogue output to A0.
Module  ->    Arduino   
- - - - - - - - - - -
GND -> GND 
VCC -> 5V

sensor Connected line sensor

Sensor testing

  • Test line sensor with: SDC_2_line_sensor_test.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_3_car_test.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

Tips

  • 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
  • Add sound
  • 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?)

Workshop

  • Presentation
    • Laptop + powersupply
    • Presentation slides
  • Electronics
    • Arduinos + usb cables
    • Motorshields (with pinheaders presoldered on the servo pins)
    • 9V battery clips
    • tcrt5000 module
    • Ultrasonic sensors
    • Protoyping cables
    • Dupont cables F-F
  • Consumables
    • Toycars
    • AA batteries
    • 9V batteries
  • Tools
    • Soldering irons
    • Tin
    • Screwdrivers
    • Wireclippers
  • Other
    • Rubber bands
    • Colored tape

External links


Used modules:

Stuff that might need explaining?

  • Digital and analog / Inputs and outputs
  • What is an h-bridge?