Now we look at the electronics. Initially, the Raspberry Pi will operate the webcam and the 4.3″ TFT (rear view monitor) screen, while everything else will be connected to the Arduino Mega. The 4.3″ TFT screen is made to operate at 12V. Intrinsically, it is actually operating at 5V, but it includes a power regulator, so it can operate in a car. There are some places on the web with instructions how to directly connect to the 5V (bypassing the built-in regulator), but the circuit in my monitor looked rather different than theirs. To keep things simple, I just went ahead and bought a step-up voltage regulator on eBay for $0.99 which converts the 5V to 12V (yes, conceptually I do hate the idea that this later down-converted to 5V, but I don’t want to deal with these details…).
I removed the screen’s foot and back plate and screwed the screen’s front plate onto the front of HAL’s case.
I got a $5 web cam that looked as much as possible like a “real” photo lens from the front. The web cam’s foot was removed, and the cam was mounted on an angular piece that was later fixed to case. Initially, I got the orientation wrong – when I connected the web cam to my laptop, it showed the picture rotated by 90 degrees. So I had to go back and flip it by 90 degrees…
Now, that’s how the monitor and web cam look from the front side:
The web cam is directly connected to one of the USB ports of the Raspberry Pi. The LCD screen is connected by an RCA connector. This requires an adapter cable (3.5mm to three RCA). But be aware that there are different types of adapter cables and not all of them work. As shown in the image, cables made for mp3 players will not work.
I got a cable for camcorders which works. But you have to connect the yellow plug from the LCD screen to the red RCA connector of the adpater (for a camcorder this would be the right audio channel, but for the RPi, this is the video input). The power input of the LCD screen is connected to the step-up converter, which is connected to the 5V output of the RPi power supply (before connecting, make sure you adjust the potentiometer on the step-up converter to something close to 12V, but not higher).
Initially, the RPi output on the screen will be ugly, but it can be improved following the next steps.
Step 1: adjust the RPi’s console font size
The available fonts are in the directory /usr/share/consolefonts/. The console font can be changed by editing the file /etc/default/console-setup. The following changes worked for me:
CODESET="Uni2"
FONTFACE="Terminus"
FONTSIZE="10x20"
Step 2: change the British keyboard to US (if needed)
edit the file: /etc/default/keyboard and change one line from
XKBLAYOUT="gb"
to
XKBLAYOUT="us"
Step 3: optimize the screen area
Edit the file /boot/config.txt
# settings for 4.3" TFT LCD
sdtv_mode=0 # for NTSC
sdtv_aspect=3 # for 16:9
framebuffer_width=480 #
framebuffer_height=272 #
disable_overscan=1 #
overscan_left=16 # increase if picture flows off to the left
overscan_right=26 # increase if picture flows off to the right
overscan_top=18 #
overscan_bottom=8 #
Step 4: display the picture of the USB web cam on the screen
The picture of the USB web cam can be displayed on the screen using the “mplayer” command
mplayer tv://
Initially, my colors were totally off. This was fixed by adding a new file “mplayer.settings” in my home directory which contained the following
run "v4l2-ctl --set-ctrl brightness=95"
run "v4l2-ctl --set-ctrl contrast=90"
run "v4l2-ctl --set-ctrl saturation=29"
run "v4l2-ctl --set-ctrl hue=-8"
This file needs to be included as input of the mplayer command “-input file=mplayer.settings”. In addition, I achieved a nice effect by lowering the frame rate to 8 fps by using the option “-fps 8”. This is how mplayer is called:
mplayer -input file=mplayer.settings tv:// -fps 8
And this is what the screen looks like with these settings: