Using an 8x2 Display with the Raspberry Pi

Surprise surprise another post from the Average Man using the ProtoCam board! If you've somehow missed my endless tweets about my new Kickstarter project, you can find out more here.
Today I'm using my ProtoCam board to make a PiCamera with a small LCD unit attached, that I will be using as a camera menu interface. It will be used to select the camera mode, give a nice message before and after the shot, and show the number of images taken.
In fact it can be used for anything you want really, LCD units are fun like that! I will look to turn this into a timelapse image & storage space display at some point.
In this project I'm using an 8x2 LCD unit from Hobbytronics, as its small size means it fits on my new ProtoCam camera module prototyping board - and it also uses the HD44780 controller that I'm familiar with from other displays.
Let's begin!

Raspberry Pi 8x2 Display

The ProtoCam does indeed 'rule'

What you need
If you want to try this project, or make something similar, you'll need the following:
- A Raspberry Pi (Model A works better for this project as it leaves even more space under the add-on board)
- A Raspberry Pi Camera Module
- A ProtoCam board
- An 8x2 LCD display (HD44780)
- A Breadboard
- Jumper Wires (mixed ends)
- 2x 8-pin male headers for the display
- 2x Potentiometer (I'm using 10k, you may wish to adjust)
- 2x Tactile Switches
- 2x 10k Resistors
- An LED
- A suitable resistor for your specific LED
- Thin wire
- Solder
- Soldering Iron
- Safety Glasses (no one likes solder spit in the eye)
- Wire Cutters/snips
Read through this post before ordering anything, to get an idea of the amount of wire and other things you may need. There are lots of other tools/helpers you may want to make use of.
Prototype the Project
It's always best to try things out as a 'dry run' as such, before soldering permanently and regretting any potential mistakes (we all make mistakes).
Solder the LCD pins
To use the LCD unit in both the prototype and the ProtoCam board, we need to give it some header pins.
Solder the 8-pin headers into the LCD holes so that the longest pin side is at the rear of the board, like this:

The longer side of the pins should be at the rear like this


Once you've done that, we can get cracking on the breadboard.
Assemble parts to the breadboard
Now we assemble the parts on to the breadboard, after which we will hook it all up to the Pi and cross our fingers!
8x2 LCD
The LCD is obviously the main piece here. Unfortunately the arrangement of the pins in this little 8x2 LCD module means it's not possible to push it straight into a breadboard (not any breadboards I have anyway), so what we need to do is kind of 'break out' the pins using female-to-male jumper wires.
Here's a picture to show you what I mean - each pin is attached to the female end of a jumper wire, which kind of makes an exploded version on our breadboard which we will then hook up to the Pi.

I've attached female-to-male jumpers to each pin... ...and it helps us 'break out' the pins, like this.


The pins match the common 16x2 LCD units you see everywhere, which use a HD47880 controller. There are usually 16 pins in a straight line with these displays, but as the 8x2 display pins are across 2 rows, I've drawn up the pin mapping from the perspective of looking at the rear of the unit:


Connect each pin as instructed above - use a labelled breakout board or Port Labels Board to help you get the pins in the right place.
Switches
You then need to add a couple of switches to the side which we will hook up to GPIO pins - this will allow us to select things on the menu we make with the code. I'm using 2 small tactile 'momentary' switches. Each one needs to be hooked up to a separate GPIO pin (I'm using 25 and 4), and will be wired up like this:

A little hint here - don't fall into the same trap as me. These little switches seem simple but you must consider how their internals work - I ended up wiring mine up wrong as I didn't realise how the 'insides' worked.
Here's a picture that Jason Barnett shared with me on Twitter to explain the internals of the switches. In a nutshell - the GPIO and GND should be on one side, and the 5V/3.3V on the other - click the switch and power joins the circuit, shoots into the GPIO pin and sets it high. Thank you Jason!

1 year of the Pi and I've only just learnt this??


Potentiometers
Push the 2 potentiometers in to your breadboard with plenty of space around them. Pin 15 and 3 from the LCD unit need to be connected to one of these each (15 in one, 3 in another), wired as follows:

LED

Finally, we wire up the LED in the usual way. I've connected the long positive leg of the LED to GPIO 14, and the short negative leg to GND. Nothing complicated about this part.

In the code the GPIO pin is set to be an output, so that we can fire power into the LED as and when we want (when the camera is on). Easy.




Wire it up!
Now connect all of these parts together as instructed above, being careful to get the GPIO pins in the right place.
The images above should give you everything you need. You can get messy with jumper wires like me, or do it the tidy way and get some of those flat ones that make much more sense.
Create The Python Script
This project was a little easier to code for me as I have used this kind of display previously with my Internet Radio. All of the displays with the HD44780 controller seem to work the same way, with just a tweak here and there depending on the size of the display being used.
My code gives you an initial display showing the number of images in the camera image save directory, and gives you an option to go to a camera selection menu.

The display shows that there are 39 images in my save directory


The menu offers you the option to take a still shot or shoot a video:

Left button to take a still, right to shoot a video


Either option will humour you with some nice messages before/after the image/video is taken, and the LED will light up when the camera is on.

Instructions are clear...


I've added notes to my script to guide you on what the various sections of code do, so that you can learn how it works and make changes to create your own spin of my creation. All part of the fun!
The script is over on PasteBin at the link below:
http://pastebin.com/UGZ6A0Rp
This is just a little fun program to test it all works - I think this would be great as a timelapse monitor to show you the % of space left in the SD card, and/or the number of images taken. Maybe even the time running. Endless possibilities!

Soldering The ProtoCam
How To Solder
Before we begin, if you're a little unsure about your soldering skills, RaspberryPiSpy has written a great post listing a collection of soldering guides, so you should find everything you need over on his blog:
http://www.raspberrypi-spy.co.uk/2014/09/learning-to-solder-is-easier-than-you-think/
The thing to remember here is you're not looking for professional factory-standard joints, just a simple soldered connection. Don't worry if it isn't very pretty, the important thing is that it works (just look at some of my examples in this post, not the best!).
Plan Plan Plan!
The important thing with boards like my ProtoCam is to take a good amount of time planning the layout before even reaching for the soldering iron. As these boards are usually Pi-sized, there's only so much space to play with, however if you're clever you can get quite a lot on them.

My mini display fits well beneath my switches...just!


So...start off with pushing the various parts into the board. You'll need to consider how to make use of the connected 'lanes' to help your soldering, space between parts, distance from the GPIO section and practicality of the finished product.

The switches have just enough space here, leaving room for the display


I guarantee you'll go through at least 5 versions of your layout before you're happy with it - but take your time and make sure it's right!
Solder The Parts
You've planned your layout, checked that it will all solder without any issues and have your soldering iron heated up ready - time to do the serious stuff!
You might think that soldering the individual components to the board first is the sensible option, however you might be wrong. Depending on your layout it's sometimes easier to solder the connecting wires first, or a mixture of the two.
It's very difficult to do a point by point soldering guide for this specific project, and part of the fun is working it out for yourself and making changes to create your own design, so here's some progress shots of my soldering to give you some ideas:

It started off easy, lots of room... ...then I added more...then more... ...then I ended up with this! Great fun!

One thing I would definitely recommend is not buying the same cheap wires that I have used. The coating melts when soldering and leaves a lot of exposed wires. There are better alternatives with a more heat-resistant coating that make life a lot easier.
After soldering the parts and connecting wires, you should end up with something like this:

Will have some fun with this at the upcoming Raspberry Pi jams

Summary
What a fun little project we have here! A great way to practice soldering and learn about new components/LCD displays, whilst creating something that can be re-coded again and again, making different menus and display text for the LCD, and different button commands including controlling the Camera Module.
Yes the ProtoCam is my design so naturally I think it's brilliant, but I do really think it gives you great flexibility for projects like this. We could have easily swapped out that display for a PIR or ultrasonic sensor, an LED matrix, Infra Red LEDs and much more.
If you want to get yourself a ProtoCam to make a project like this, It's currently on Kickstarter open for pledges.

Continue reading here: Raspberry Pi Time Lapse Code Example

Was this article helpful?

0 0