Radio Controlled Car with Flyport openPICUS via Wireless Connection

Posted by openPicus | On: Jan 19 2012

Do you remember HackItaly? Well, TheBoss Bear, a participant wrote for us his experience!

Two months ago, I participated at HackItaly that allowed me to meet the young openPICUS Team and its wonderful jewel: Flyport.

So, me and my teammates, we interfaced a toy car built by Stefano Saccucci with the Microsoft Kinect, obtaining a guidance system controllable with the movement of the arms: great! In addition, we added a Nokia 5800 + “SmartCAM” software in order to have a webcam on board and make driving more interesting.

We won the first prize of Microsoft and the second prize of openPICUS which was of 2 Flyports. I kept one Flyport because I wanted to create a toy car similar to that created by Stefano and, with his everlasting help, I did it!!

The first problem I encountered was the following: “What do I need?”

Theoretically, said Stefano, you need an engine, a mini-servo motor and the bodywork. The engine to control the movement and the speed; the mini-servo motor to control the direction and the bodywork to put the circuits and the battery.
It seemed to be very simple. My second problem, was: “How do I control the engine with 5 or 6V if the Flyport OUT pins have lower voltage?”

L293D is a component which implements an H-bridge and it lets you control with an input voltage another voltage and it also allows the output to a pin rather than another, so as to control the direction (can control up to 2 voltages at a time). I managed to find the L293D but I had some problems to find the engines and the mini-servos. So I bought a radio controlled toy car at 20€: a small Mercedes-Benz GLK350 4Matic. Unfortunately I discovered that instead of having a servo motor to control the direction of the rear wheels, using an engine, making “discrete” rotations of the wheels: either all right or far left or straight. So with the purchase of the toy car, after removing the internal circuits, I was having the bodywork and 2 4.5V engines. I bought a breadboard card that I cut and adapted to the toy car, where I then soldered and connected a L293D to the engines, to the current, following the scheme:

The picture on the right there is a mistake: I reversed the “Out” at the left bottom with “Engine” on the red wire. “Engine” is the engine that moves the toy car, “Engine 2″, controls the direction. Reading from left to right, from top to bottom, I have connected the “Outs” respectively to o2, i1, a3, i2.

Whereupon I closed everything and took a look to the firmware. After some test, I am was pleased to see that the motors work great. Here’s some code:

#include “taskFlyport.h”
signed char vel = 0;
signed char angle = 0;
void FlyportTask()
IOInit(i1,OUT); //IN1
IOInit(i2,OUT); //IN2
IOInit(i3,OUT); //IN3
IOInit(i4,OUT); //IN4
IOInit(i5,OUT); //IN5
while (WFStatus != CONNECTED);
IOPut(o5,off); //disattivo lucina del wireless
IOPut(o1,on); // accendo dei faretti anteriori
PWMInit (4, 100, 0); //inizializzo la PWM per controllare la potenza del motore 1
PWMOn (D4Out, 4);
xTaskCreate(listener, (signed char*) “tcp listener”, 200, NULL, 1, NULL); //lancio task in ascolto su connessione TCP
signed char oldvel=0;
signed char oldangle=0;
PWMDuty(4,0); // disattivo la pwm e quindi il motore
int temp = vel>0?On:Off;
int temp2 = vel<0?On:Off;
IOPut(o2, temp); //OUT per l’avanti
IOPut(o3, temp); //OUT per il dietro
IOPut(i1, Off); //controllo il motore 2 solo con On o Off, giacché il movimento è discreto
int temp = angle>0?On:Off;
int temp2 = angle<0?On:Off;
IOPut(i2, temp); //OUT per la sterzata a destra
IOPut(i3, temp); //OUT per la sterzata a sinistra
IOPut(i1, On);

The data are sent via TCP socket in the format: {SYMBOL} {VALUE}. Example: To set the speed to 40% I send the string “S (” symbol “(” has a value of 40. In bytes: 83:40 (decimal) To set the angle on the right I send “65:01″ (65 stands for “A”) If you want you can choose the symbols above the 100th (being careful to the negative values​​) to be sure that the symbols have different values ​​from the % of power on the engine. This is the part of the task server:

void listener(){
static TCP_SOCKET Socket;
UARTWrite(1,”Server creato\r\n”);
unsigned char minibuff[2];
int tcplen;
if((tcplen=TCPRxLen(Socket))<2) //aspetto che ci siano almeno 2 byte da leggere
TCPRead(Socket, minibuff, 2);
vel = (signed char)minibuff[1]; //-100 <-> 100
else if(minibuff[1]==’A’){
angle = (signed char)minibuff[1];//-100, 0, 100
else {
UARTWrite(1,”Non sono connesso\r\n”);
It was be missing only the client on the computer that I decided to develop in C#, for its convenience to manage the connections. I also wanted to put the Nokia 5800 as webcam in order to make the ride more interesting!  Here's the video:  
Then I also tried to add a horn/buzzer, getting a funny effect. And to be honest, it’s definitely been an interesting experience and I understood the potential and the limitations of Flyport, dictated mainly by the imagination of those who have it between the hands!
Note: the original source of the firmware have been lost. Those proposed here, there are only to give an idea of the original operation. It could cause problems regarding the management of the buffer socket that is emptied slowly and may contain syntax errors. I apologize in advance”, concluded TheBoss Bear. A big Thank you to TheBoss Bear for sharing with us not only his experience but also his project! Do you have a Flyport Project?! Well, contact us to publish it on openPICUS channels!


  1. This piece is very informative! :) Thanks for this!

  2. Sensational info. I look forward to seeing more.
    wifi robin

  3. You have posted about radio controlled cars with flyport openPICUS via wireless connection. I really likes this post. Very informative!

Leave a comment