RaspberryPi-car Project is RaspberryPi based on.
This article has three parts.
I participate in "The Undergraduate Innovative Experimental Program". This project is one of the important part.
-
3.3v TTL convert to 5.0v TTL.
Connect to RaspberryPi by serial.

-
The motor driver chip with much better performence comparing to L298N.
-
The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats or dolphins do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package. From 2cm to 400 cm or 1” to 13 feet.
Used for avoiding obstacles.

-
Votage: 11.1v
Discharge current: 25C
Usage: power motor and servo -
Votage: 5v
Discharge current: ?C
Usage: power RaspberryPi and Arduino
-
Arduino Serial is repeatedly waiting for commond composed by the three bits of instruction. These three bits represent direction(0 or 1), motor speed(0-255) and steering angle(0-180).
-
Two motor control signal line attach to arduino PIN11 and PIN12. The PWM output pin is PIN11.
The setPwmFrequency() method change the default frequence at PIN11 to 31250 Hz decreasing the noise from motor. -
The Servo control signal line attach to PIN9. Use the arduino servo lib.
-
Used Pins : 2, 4 Use the arduino lib NEWPING.
- HomePage
- Module B
- System Raspbian
- QuickGuide
Create a pipe sending the commond to Arduino at '/dev/ArduinoServer'.
The commond format is 'M=S'.
'M' indicated the power of moter between -255,255.
'S' indicated the servo steering teach between 0,180.
Both 'M' and 'S' are string. They are split by '='.
The shell commond to make it is as follows:
sudo apt-get install python-serial
sudo cp ./RaspberryPi/pyctrl/arduinoserver.py /usr/local/bin
sudo cp ./RaspberryPi/init.d/ArduinoServer /etc/init.d/
sudo update-rc.d ArduinoServer start You can try echo 255=90 > /dev/ArduinoServer to let the car forward at full speed.
Also try echo 150=50 > /dev/ArduinoServer to let the car turn right.
Controlled by TCP Set up a server waiting for TCP connecting at port 2013. The data expected is the commond sending by the controller via TCP connection.
The format of TCP commond is defined : "M S"/.
'M' indicated the power of moter between -255,255.
'S' indicated the servo steering teach between 0,180.
Both 'M' and 'S' are strings. They are split by ' '.
The shell commond to make it is as follows:
sudo cp ./RaspberryPi/pyctrl/carserver.py /usr/local/bin
sudo cp ./RaspberryPi/init.d/CarServer /etc/init.d/
sudo update-rc.d CarServer start - The Mjpg-streamer project. The project homepage is "http://sourceforge.net/projects/mjpg-streamer/".
- For more information click here.
- For Raspi Camera Module click here.
sudo apt-get install cmake imagemagick libjpeg8-dev
sudo cp ./RaspberryPi/init.d/webcam /etc/init.d/
sudo update-rc.d webcam start
cd RaspberryPi/mjpg-streamer-code-181/mjpg-streamer-experimental-pi/
make && sudo make install
- Run the car's homepage on lighttpd which is a light http server.
- The code of homepage is written in HTML5.
- The control device must support gravity sensing . The car is controlled by the sensing.
sudo apt-get install lighttpd python-flup
sudo lighttpd-enable-mod fastcgi
sudo cp ./RaspberryPi/10-fastcgi.conf /etc/lighttpd/conf-enabled/
sudo cp -r ./RaspberryPi/www/* /var/www
sudo /etc/init.d/lighttpd force-reloadhostapd
isc-dhcp-server
lighttpd
mjpg-streamer
arduinoserver.py
carserver.py
Code :
sudo apt-get install vim python-serial python-flup lighttpd hostapd isc-dhcp-server imagemagick libjpeg8-dev cmake
sudo cp ./RaspberryPi/pyctrl/* /usr/local/bin
sudo cp ./RaspberryPi/init.d/* /etc/init.d/
sudo update-rc.d ArduinoServer start
sudo update-rc.d CarServer start
sudo update-rc.d webcam start
sudo lighttpd-enable-mod fastcgi
sudo cp ./RaspberryPi/10-fastcgi.conf /etc/lighttpd/conf-enabled/
sudo cp -r ./RaspberryPi/www/* /var/www
sudo /etc/init.d/lighttpd force-reload
cd RaspberryPi/mjpg-streamer-code-181/mjpg-streamer-experimental-pi/
make && sudo make install


