Car Driver Shield
This is a library for Elechouse Car Driver Shield ,
Instruction
Files
- CarDriverShield.h - library header file
- CarDriverShield.cpp - library source file
- exmples - samples folder.
- car_driver_shield_sample0.ino - sample
- image - some related images
- keywords.txt - Add keywords Arduino key words list, this benefits your developing.
Functions
CarDriverShield - library class name, use to declare a user class for using library.
begin(int led_num) - CarDriverShield initial function. Must be called in setup() of arduino. led_num
=-32768 means no LED is needed.
forward() - car run forward
backward() - car run backward
decelerate() - car run decelerate
accelerate() - car run accelerate
turn_left() - car run turn_left
turn_right() - car run turn_right
evt_loop() - CarDriverShield event loop, handle speed refreshing and LED control.
How to
This is a quick start guide, which aims to teach you how to use this CarDriverShield library and tell you what you need prepare for using.
Prepare
- Arduino Nano board
- Car Driver Shield
- A toy car board with four motors(2 motors a group), like this
Assemble
- Plug your Arduino Nano into Car Driver Shield.
- Fix Car Driver Shield in your Toy Car.
- Parallel connect the two left side wheels, anode to anode, cathode to cathode, then connect the anode(+) of the left wheels to the OUTA-1 and the cathode(-) to OUTA-2
- Just do as part 3, parallel connect the two right side wheels, anode to anode, cathode to cathode. Then connect the anode(+) of the right wheels to the OUTB-1 and the cathode(-) to OUTB-2.
- Connect the battery.
Upload
-
Download CarDriverShield.
#get through GIT tools : git clone https://github.com/elechouse/CarDriverShield.git
or
#download zip file
-
Extract the zip file if you download the zip format file. Copy CarDriverShield to $ArduinoSketch/libraries .
Note: $ArduinoSketch means your Arduino sketchbook location, you can find it by opening ArduinoIDE->File->Preferences or shortcut Ctrl+comma
-
Restart your Arduino IDE.
-
Open car_driver_shield_sample0. (ArduinoIDE->File->Examples->CarDriverShield->car_driver_shiled_sample0)
-
Connect your Arduino Nano to PC, select exact Serial Port, select exact arduino Board.
-
Hit upload button, wait to be uploaded.
-
Now you can control you Toy Car through serial port(Default : 115200,8,N,1),
Most people may need to control your car by wireless way, here is some recommended way:
- Wifi Car (Strongly recommended)
- Bluetooth Car (see this Serial Bluetooth Module
- 2.4GHz Car (see this 2.4GHz Module)
- may be more ...
Run your car
Control your car by sending these characters:
- w --> forward;
- s --> backward;
- a --> turn left;
- d --> turn right;
- e --> accelerate;
- c --> decelerate;
- z --> stop;