Self-driving Toycar: Difference between revisions
No edit summary |
|||
Line 9: | Line 9: | ||
=== Deconstuct the car === | === Deconstuct the car === | ||
* Remove the screws to remove the top. | * Remove the screws to remove the top. | ||
* Cut of all the wires going to the | * Cut of all the wires going to the PCB, as close as possible to the PCB. (make sure the power switch keeps working and that it is off) | ||
[[File:UNADJUSTEDNONRAW_thumb_15ce.jpg|500px|strip]] | [[File:UNADJUSTEDNONRAW_thumb_15ce.jpg|500px|strip]] | ||
=== Test the Arduino and the Arduino software === | |||
'''Open your first sketch''' | |||
Open the LED blink example sketch: File > Examples >01.Basics > Blink. | |||
[[File:UNO_Load_Blink.jpg]] | |||
'''Select your board type and port''' | |||
You'll need to select the entry in the Tools > Board menu that corresponds to your Arduino or Genuino board. | |||
[[File:UNO_BoardType.jpg]] | |||
Select the serial device of the board from the Tools | Serial Port menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your board and re-open the menu; the entry that disappears should be the Arduino or Genuino board. Reconnect the board and select that serial port. | |||
[[File:UNO BoardType.jpg]] | |||
'''Upload the program''' | |||
Now, simply click the "Upload" button in the environment. Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will appear in the status bar. | |||
[[File:UNO Upload.png]] | |||
A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to blink (in orange). If it does, congratulations! You've gotten Arduino or Genuino up-and-running. | |||
=== Connect the Motor driver === | === Connect the Motor driver === |
Revision as of 15:05, 1 March 2017
Workshop manual
Team up!
- Form teams of 3-4 people
- Give your team a name!
Deconstuct the car
- Remove the screws to remove the top.
- Cut of all the wires going to the PCB, as close as possible to the PCB. (make sure the power switch keeps working and that it is off)
Test the Arduino and the Arduino software
Open your first sketch
Open the LED blink example sketch: File > Examples >01.Basics > Blink.
Select your board type and port
You'll need to select the entry in the Tools > Board menu that corresponds to your Arduino or Genuino board.
Select the serial device of the board from the Tools | Serial Port menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your board and re-open the menu; the entry that disappears should be the Arduino or Genuino board. Reconnect the board and select that serial port.
Upload the program
Now, simply click the "Upload" button in the environment. Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will appear in the status bar.
A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to blink (in orange). If it does, congratulations! You've gotten Arduino or Genuino up-and-running.
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
- 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
Motors test over serial connection
- Connect Arduino to your computer
- Install Arduino Software
- Test with sample code
- After downloading the zip file from Github open SDC_1_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 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.
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
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
- Spare batteries!
- Rubber bands!
- Tape!
- Soldering irons!
External links
- HC-SR04 ultrasonic sensor library. https://bitbucket.org/teckel12/arduino-new-ping/downloads
- L293D https://github.com/sudar/DCMotorBot
Used modules:
- https://www.hobbyelectronica.nl/product/l293d-motor-shield/
- https://opencircuit.nl/Product/10540/TCRT5000-Infrarood-lijn-detectie-module-met-instelbare-gevoeligheid
- https://opencircuit.nl/Product/10037/Ultrasonische-afstands-detectie-module
Stuff that might need explaining?
- What is an h-bridge?