This project will make remote car control which can view camera attached on car.
It will need:
Hardware side:
1. Car toy
2. Two gear motor
3. Raspberry B+
4. Wifi dongle
5. Power bank (10A) (for Raspberry board)
6. Battery (for gear motor)
7. H-bridge circuit (L298N)
Software side:
1. Install camera using ffmpeg (Link)
2. Install Local web (Apache)
3. Make web page to control
4. Control through Internet (by port forwarding)
Step 1. Make a car
Install gear motor to car toy. It will need your clever hand and some thinking to put all things in right way
Also put H-bridge inside the car
Briefly introduction about H-bridge:
H-bridge is used to control motor direction: to make motor run clockwise A1 and A2 must be ON; run counter clockwise B1 and b2 must be ON
Above image is type of Mechanical H-bridge using relay, this project will use H-bridge from IC L298N
This electronics H-bridge also have 4 inputs A1 A2 B1 B2 (indicated in PCB is IN1 IN2 IN3 IN4) which will triggered by Raspberry GPIO
Make connection from Raspberry to H-bridge
This project connect:
GPIO0 - IN1
GPIO2 - IN4
GPIO3 - IN3
GPIO4 - IN2
GND Raspberry - GND H-bridge
For example, to make car run forward -> 2 motor have to run clockwise -> IN2, IN4 should be ON; IN1, IN3 should OFF -> GPIO2, GPIO4 should ON; GPIO0, GPIO3 should OFF
In previous article, follow instruction there to install ffmpeg into Raspberry (Link here)
Step 3. Make a web page to control
Install Apache and php by following command
sudo apt-get install apache2 php5 libapache2-mod-php5
After installation, input Raspberry IP address (this case is 192.168.1.71) in Web browser to see if local web working or not. If working, it will have result as here:This webpage is saved at /var/www/html/
Next is making a local web which will load camera image on Step 2, and have 4 buttons to control motor of car
cd /var/www/html/
gedit camera.php
gedit camera.php
Then, input following content:
file /var/www/html/camera.php
<html>
<head>
<meta charset="utf-8" />
<title>Raspberry Pi - Camera rotate</title>
</head>
<body style="background-color: white;">
<center>
<img height="240" width = "320" src="http://192.168.1.71:8090/test.mjpg" />
<br>
<button id="myP" onmousedown="mouseDown(02)" onmouseup="mouseUp(02)">Backward</button>
<button id="myP" onmousedown="mouseDown(03)" onmouseup="mouseUp(03)">Turn right</button>
<button id="myP" onmousedown="mouseDown(37)" onmouseup="mouseUp(37)">Forward</button>
<button id="myP" onmousedown="mouseDown(27)" onmouseup="mouseUp(27)">Turn left</button>
<br>
<!------------------------------------------------ php -->
<?php
//set the GPIO0, GPIO7 mode to output
system("gpio mode 0 out");
system("gpio write 0 0");
system("gpio mode 2 out");
system("gpio write 2 0");
system("gpio mode 3 out");
system("gpio write 3 0");
system("gpio mode 7 out");
system("gpio write 7 0");
//-----update button status
$output = shell_exec("cat temp");
if ($output ==0) {
echo ("<img id='status' height=48 width = 120 src='data/ON.png'/>");
}
else {
echo ("<img id='status' height=48 width = 120 src='data/OFF.png'/>");
}
?>
</center>
<!------------------------------------------------ javascript -->
<script src="camera.js"></script>
</body>
</html>
<head>
<meta charset="utf-8" />
<title>Raspberry Pi - Camera rotate</title>
</head>
<body style="background-color: white;">
<center>
<img height="240" width = "320" src="http://192.168.1.71:8090/test.mjpg" />
<br>
<button id="myP" onmousedown="mouseDown(02)" onmouseup="mouseUp(02)">Backward</button>
<button id="myP" onmousedown="mouseDown(03)" onmouseup="mouseUp(03)">Turn right</button>
<button id="myP" onmousedown="mouseDown(37)" onmouseup="mouseUp(37)">Forward</button>
<button id="myP" onmousedown="mouseDown(27)" onmouseup="mouseUp(27)">Turn left</button>
<br>
<!------------------------------------------------ php -->
<?php
//set the GPIO0, GPIO7 mode to output
system("gpio mode 0 out");
system("gpio write 0 0");
system("gpio mode 2 out");
system("gpio write 2 0");
system("gpio mode 3 out");
system("gpio write 3 0");
system("gpio mode 7 out");
system("gpio write 7 0");
//-----update button status
$output = shell_exec("cat temp");
if ($output ==0) {
echo ("<img id='status' height=48 width = 120 src='data/ON.png'/>");
}
else {
echo ("<img id='status' height=48 width = 120 src='data/OFF.png'/>");
}
?>
</center>
<!------------------------------------------------ javascript -->
<script src="camera.js"></script>
</body>
</html>
Save file, go to web browser, input 192.168.1.71/camera.php will see camera image come along with 4 buttons
To make those buttons working with 2 motor (e.g: push "Backward" button, 2 motor should run anti-clock wise; so on for other buttons), two more files need to be done:
(1) The file camera.js contains mouse_up and mouse_down function for Raspberry GPIO, also update this signal come to Raspberry or not.
(2) The file camera_rotate.php receive content from camera.js, then will apply GPIO output command, which make GPIO in state 0V or 5V
This project web page can be download at here (Google share)
All files should be saved in /var/www/html
From now, go to local web (192.168.1.71/camera.php) -> can see: camera image & car wheel will rotate if button is clicked (wheel will stop when button is released)
Step 4. Put all thing in car
Attach power bank in car. This power bank will feed Raspberry board
Attach camera, another power for H-bridge motor, and car cover
Done! Now open Local web at 192.168.1.71/camera.php to control it
4. Control through Internet (by port forwarding)
In order to control through Internet (any where in world!), port need to open in Router
At Raspberry:
Change port of /etc/apache2/ports.conf from 80 to 8082
Change port of /etc/apache2/sites-enabled/000-default.conf from 80 to 8082
At Router:
Depend case on case at Router manufacturer, follow Router manual to open port 8082 for Local web, and port 8090 for camera
Now, finding Internet IP address by webpage, eg. http://www.canyouseeme.org/
Put internet IP address with Raspberry webpage, now the car can control anywhere in world!
You might also like:
1. Rasbperry pi - FFmpeg install and stream to web
Following tutorial will show how to install FFmpeg into Raspberry Pi, then stream video to Local web which can be access through Computer/Phone/Tablet
This comment has been removed by the author.
ReplyDeleteNice article, Thanks for sharing.
ReplyDeleteDesh Cam Buying Guide
Hi Dear,
ReplyDeletei Like Your Blog Very Much..I see Daily Your Blog ,is A Very Useful For me.
Speed Muscle Remote Control RC Buggy 2.4Ghz 1:16 Scale Truggy Ready to Run w/ Suspension Toy (Green Color) …
Visit Now - https://www.amazon.com/Speed-Muscle-Remote-Control-2-4Ghz/dp/B01M712G8Y/ref=sr_1_1?m=A3KIGJ5D7AQK8I&s=merchant-items&ie=UTF8&qid=1504848759&sr=1-1&keywords=B01M712G8Y
Remote Control Car
Hi Dear,
ReplyDeletei Like Your Blog Very Much..I see Daily Your Blog ,is A Very Useful For me.
remote control car Buy RC Remote Control Car 2.4 GHz Monster Formula Car 3-in-1 DIY Interchangeable Transforming Kit Toy Car 1:16 RECHARGEABLE (Black/Green): Toy RC Vehicles - Amazon.com ✓ FREE DELIVERY possible on eligible purchases
Hi Dear,
ReplyDeletei Like Your Blog Very Much..I see Daily Your Blog ,is A Very Useful For me.
remote control car Buy RC Remote Control Car 2.4 GHz Monster Formula Car 3-in-1 DIY Interchangeable Transforming Kit Toy Car 1:16 RECHARGEABLE (Black/Green): Toy RC Vehicles - Amazon.com ✓ FREE DELIVERY possible on eligible purchases
ReplyDeleteGPS Tracking including vehicle cameras and Incident Camera, back-up cameras and public transportation
surveillance, all at affordable prices.
https://www.sure-track.co.uk/how-sure-track-helps/incidentcam-vehicle-cctv
GPS Tracking including vehicle cameras and Incident Camera, back-up cameras and public transportation surveillance, all at affordable prices.
ReplyDeletehttps://www.sure-track.co.uk/how-sure-track-helps/incidentcam-vehicle-cctv
I Like Your Blog Very Much. Click crisp images with the help of remote control drone with a camera. Our RC drone’s feature latest cameras that can help you capture crisp and clear images. Visit us today to shop your favourite items online at highly reasonable prices.
ReplyDelete
ReplyDeletesure-track Provides 24/7 Online GPS Car Tracking Solution. Track your vehicle real time from web and smartphone. Ensure safety of your Kids, Parents and Teen. We provide GPS based Personal Car Tracking Device.
https://www.sure-track.co.uk/how-sure-track-helps/monitor-plug-play-vehicle-tracking/
Do you want to buy remote control Wifi drone with camera? Droneshop7 is definitely the right choice for you. Here, get the collection of drones that are suitable for both indoor and outdoor flying in dark night as well as day.
ReplyDeleteok :)
DeleteFurthermore, dash camera reviews despite the fact that I trust that this will never be the situation, how might I say that I will never under any circumstance become associated with a car crash?
ReplyDeleteAnother person has paid that for you. You have decreased the danger of burring yourself in that car monetarily. private car sales
ReplyDeleteThis blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. Serious Security Bayswater
ReplyDeleteThanks
ReplyDeleteGood morning,
ReplyDeletethank you for your tutorial!
I download the html.zip folder
I can’t configure the commands of both engines.
In your camera_rotate.php
//code
//--------------------------------------------backward
if (($rotate == 1)&&($pin == 02)){
// run back-ward
shell_exec("echo 0 >temp");
$rotate = 0;
system("gpio write 0 1");
system("gpio write 2 1");
system("gpio write 3 0");
system("gpio write 7 0");
}
{else
if (($rotate == 0)&&($pin == 02)){
// stop back-ward
shell_exec("echo 1 >temp");
$rotate = 1;
system("gpio write 0 0");
system("gpio write 2 0");
system("gpio write 3 0");
system("gpio write 7 0");
It's the gpio 7 (or gpio 4) ?
thanks
wow wow, let's try it yourself first. I made this project long time ago, i can't remember about it. However, i don't think my code is wrong because it already run.
DeleteHello,
ReplyDeleteIt's work !
cool job !
i'm glad to hear that. Thanks for your visit!
DeleteMonster trucks must have captured your child’s imagination at least once – so the delight that will light up his face when he sees this bad boy should not come as a surprise. The MaxTronic Monster RC Car
ReplyDeleteIf you could possibly were recently laid-off from employment in the i.t sector, or think you're new graduate, you should think about IT jobs where you could telecommute. ycombinator startup templates
ReplyDelete