Day 25: MC-1 Part IV: Steering using a servo

The first version of the MC-1 (Monster Car 1) presented on days 20, 21, and 22 used a solenoid to steer the wheels. Unfortunately, that approach did not work at all–I think I broke the solenoid 😦 –so I decided to replace it by a servo.

The first step was remove the solenoid and the enclosing box and cut the plastic to make room for the servo.


I have made a hole in the plastic to attach the servo using a machine screw and a nut. I have attached the other side of the servo to a L-shape servo support. The support itself was fixed to the chassis using a self tapping screw because that part of the chassis was very thick.

I have made a hole in the steering bar and connected it to the servo wheel using a paper clip.


The final result is very good, as we can see in the following pictures.




This picture shows the servo in the car with the wheels on the ground.


I am not using the whole range of positions the servo provides. The pulses width are from 1000 µs to 2000 µs.

Day 24: Controlling a relay with the Raspberry Pi

In order to control the circuit presented on Day 23 with the Raspberry Pi, I used the L293D motor driver.

The relay requires 40 mA and the GPIO can provide up to 16 mA. Using the L293D motor is a little overkill since it can handle up to 600 mA. I believe that the ideal solution would be using a transistor as shown in this article but I don’t have one now.

It is extremely important to use the protection diode in the proper position. I have been told that the 1N4148 is more suitable for this because it has a better response time. By now, I only have a 1N4001. I have read in some blogs people saying they use the 1N4001 without problems, so I gave it a chance.


I used the GPIO #17 pin to activate the relay through the L293D. I connected +5V from a external power source to the line in the top of the image  and its ground to the line in the bottom of the image.

As usual, I used my PiEater library to control the GPIO from my desktop computer. Since this is just a quick test, I added a new check box in my previous Truck Driver program:


And, voilà!

Green  Red

Day 22: MC-1 Part III: First test

Although nothing caught fire, things did not work the way I intended them to:

  • The workaround used to activate the solenoid did not work. The front wheel barely turned.
  • The speed slider was calibrated with the wheels on the air. When the car was on the ground, it took almost full power to start moving it, although it was possible slowing it down once it was moving.
  • The live video feed (as described on Day 18) presented two to four seconds of lagging.
  • The camera shakes a lot when the car is moving.

Despite these enhancement opportunities, I consider it a success. It is my first successful circuit since I was in the 6th grade. I learnt a lot of things and had lots of fun. When I was at the University, I had a very frustrating experience trying to use the 8031 micro-controller.

For the future, I am considering the following possibilities:

  • Use relays to activate the solenoid or replace it for a servo to turn the front wheels.
  • Replace the L293D (600mA) for the L298N(2A).
  • Replace the nc program used to stream the video over the network for a home made one. Maybe replace the video for still pictures.
  • Change the camera position and/or add some shock absorber device.

Day 21: MC-1 Part II: Software

Since programming and testing on the Raspberry Pi itself is not very productive, I have created a TCP/IP library to send commands to the ServoBlaster from a Windows .NET program. I named it PiEater. My Raspberry Pi has a WiFi USB token, so I can access it without the usage of cables.

I wrote the “Truck Driver” program for the MC-1:


The speed slider changes the pulse width sent to the motors through the L293D. Since it is a little harder to find the center of the slider, I added a “Stop” button that does that. The slider allows going from full power to back to full power to front.

The camera position sliders act on the servos mounted under the camera. The “Center” button centers the camera in both  horizontal and vertical axes.

Day 20: MC-1 Part I: Hardware

The MC-1, abbreviation for Monster Car 1, is based on parts of a car that once was remote controlled. My wife chose this name because she thinks it is ugly as a monster.

The front wheels are turned by a solenoid. Since the current provided by the L293D is limited, I created this workaround. When the servo moves, it causes the paper clips to close an electric circuit and activate the solenoid.


I have created a standard for the wiring–The connectors that provide power are females and the one that receive power are males. Hence, I don’t have energized male connectors touching each other causing short-circuits. I used glued tape to group the wires together and label them. In this way, it will be easier reconnect the chassis to the board.

MC1-Board MC1-Chassis

I used Velcro to attach the breadboard and the Raspberry Pi to the car. This is how the final assembly looks like.


Day 18: Installing the camera

I followed the instructions described in the Mod my Pi blog:

First step: Update the system:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove

Second step: Enabling the camera

sudo raspi-config


Third step: Installing the camera

  • Shutted down the system, removed the power cable, video cable, sd card, etc
  • Followed James Adams’ video at YouTube:

Fourth step: Taking pictures

raspistill -o raspbox.jpg


We can also shot videos:

raspivid -o video.h264 -t 5000

These programs have several options for setting resolution, file format, etc

Day 17: Controlling a DC motor

I bought this car in a second-hand-stuff shop. Originally it was remote-controlled but when I bought it, it no longer had the remote control. I don’t know the motor specification. This car has five AA batteries (7.5V), so I think it is safe to use my 5V power source. I put it on a box to avoid it to run away.


This time I used the L293D attached to GPIO 18 and 23 in a way I can make the motor run forwards or backwards.


I used the Servo Blaster library as presented on Day 14. In order to run the motor forwards, I kept one signal at zero and changed the other one.

echo "2=0" > /dev/servoblaster

echo "5=500" > /dev/servoblaster

To run backwards, I inverted the signals:

echo "5=0" > /dev/servoblaster

echo "2=500" > /dev/servoblaster

It worked with values from 300 to 2000.

When the motor runs forwards, the white LED is on. The LED is connected after the L293D.


When the motor runs backwards, the green LED is on. The LED is connected before the L293D.