I made a four-wheel automatic cruise robot using Arduino and kinds of sensors. Then I added wireless remote
control to it. In the end, I even built an air quality monitoring machine on the robot and it turned to be very useful.
Please vote for me and thanks a lot!
Main: Arduino mega2560; 4wheel car; four DC motors with reduction gear; L298N driver circuit board; apc-220 RF modules (RF communication); four ultrasonic distance sensors; infrared ray distance sensor; 3s(11.1v) li-battery; air quality sensor(I used SHARP GP2Y1010); 1602 LCD; SD card module
Else: breadboard; wire; computer;
Software: Arduino IDE; office excel; serial assistant;
Step 1: Step One:
Assemble a four-wheel car. Any kind is ok and mine is a 32cm*26cm*13cm one and its 13cm wheels make it easy to step overobstacles encountered.
Step 2: Step Two:
Connect the wheels with DC motors using reduction gear.
The slower the wheels’ speed, the larger the torque gained. So choosing a suitable reduction gear is of vital
Step 3: Step Three:
Connecting four motors with L298N board. 4*2=8 wires in total
L298N is a driver board for DC motors. It allows larger current (Arduino I/O only has 40ma per pin) and uses three wires for controlling a motor (two for rotation direction and one for speed).
Motors-L298N board: 4*2=8 wires in total
L298N borad-arduino: 4*3=12 wires in total
DC battery-L298N board: 2 wires in total
Attention one: L298N board needs a common GND with Arduino
Attention two: L298N’s speed control pins
should connect with Arduino’s digital pin which is able to give PWM signal. (Different Arduino board is different)
Step 4: Step Four
Make a stand for fixing four ultrasonic distance sensors and attach them on the stand. The side-to-side width is
supposed to be the same with car’s width.
Connect ultrasonic distance sensors with Arduino digital pin.
In my case, I connect VCC to 3.3V output; GND to GND; trig pin and echo pin to any digital pins of Arduino.
Thatis 4*4=16 wires in total.
Step 5: Step Five
Because relying on four ultrasonic distance sensors is not a perfect idea. The car still misses some small obstacle in reality so I test and add an infrared ray distance sensor. It is also a distance sensor and if faced with some obstacle it can give a low voltage feedback.
It has only three pins: VCC, GND, SIGNAL and the signal pin should be connected to one
of Arduino’s interrupt pin. (can look up on www.Arduino.cc for a specific Arduino board)
Step 6: Step Six (remote Control and Communication.This Part Is Optional)
I used APC-220 module, a RF module ranging from 400MHZ to 490MHZ, for this function. Use the USB converter to connect two modules with computer and set their frequencies and baud rate for same.
APC-220 uses 5V as power and serial communication with Arduino (pin RX and TX) so it is kind of easy. And just
including ”serial.begin (9600)” in your Arduino program’s setup enables you to remote control the car and even get the sensors’ data you want.
Step 7: Step Seven
Assemble the air quality monitoring sensor (SHARP GP2Y1010) with Arduino.
The connection instruction is illustrated in the figure.
It is an air sensor based on the particles’ reflection, which makes the air quality a visible measurement. You just read and analyze the voltage it feeds back and each voltage corresponds to a specific particle density.
The code of handling the voltage feedback is below.
int measurePin = A0; //Connect dust sensor to Arduino A0 pin
int ledPower = 2; //Connect 3 led driver pins of dust sensor to Arduino D2
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
float voMeasured = 0;
float voMeasuredReal = 0;
float voMeasuredLast = 123.0;
float calcVoltage = 0;
float dustDensity = 0;
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
lcd.init(); // initialize the lcd
// 0 - 5V mapped to 0 - 1023 integer values
//calcVoltage = voMeasured/5.0*5.5;
//dustDensity = 0.17 * calcVoltage - 0.1;
digitalWrite(ledPower,LOW); // power on the LED
voMeasured=analogRead(measurePin); // read the dust value via pin 5 on the sensor
digitalWrite(ledPower,HIGH); // turn the LED off
else if (voMeasured<220)
//if (dustDensity<0) dustDensity=0.0;
if (dustDensity>600) dustDensity=600.0;
// if (i<=30)delay(1000);
// else delay (5000);
// if (i>1024) i=31;
Step 8: Step Eight (LCD and SD Card. Also Optional)
Only getting the air quality is not enough, I need to get these data.
There are many ways to achieve this. For example, apc-220 remote communication, LCD showing, SD card save and so on. And this time I will show how to use a 1602 LCD to show the information.
My 1602 LCD has for pins because it is already combined with a module which enables the LCD using I2C to communicate with Arduino.
The four pins are VCC, GND, SDA, SCL in respect. Though Arduino boards are different, they all have analog pin4 and pin5, which can be used as I2C. Just connecting the SDA to A4 and SCL to A5 and all is done.
There is already LiquidCrystal_I2C library file for Arduino. Put this library file to your computer Arduino IDE’s folder and you can use the LCD easily.
Step 9: Result
First of all, my car can automatic cruise avoiding obstacles due to its ultrasonic distance sensors and infrared ray distance sensor (as emergency interrupt).
Then, I can remote control (around 800m) my car and even make it cross stairs and other tough obstacles.
Next, it can monitor the local air quality. Though it is probably not as accurate as the Meteorological monitoring department, it does tell you a relatively air quality just where and when it is. I think this is also brilliant.
Finally, I collect some samples and plot them in execl. It is a lot of fun.
Thanks for your reading and really wish your appreciation and vote.
If any question, please feel free to ask, either comment or email is ok. (email@example.com)