Arduino and KTM-S1201 LCD modules

Learn how to use very inexpensive KTM-S1201 LCD modules in this edition of our Arduino tutorials. This is chapter forty-nine of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Introduction

After looking for some displays to use with another (!) clock, I came across some 12-digit numeric LCD displays. They aren’t anything flash, and don’t have a back light –  however they were one dollar each. How could you say no to that? So I ordered a dozen to try out. The purpose of this tutorial is to show you how they are used with an Arduino in the simplest manner possible.

Moving forward – the modules look like OEM modules for desktop office phones from the 1990s:

With a quick search on the Internet you will find a few sellers offering them for a dollar each. The modules (data sheet) use the NEC PD7225 controller IC (data sheet):

They aren’t difficult to use, so I’ll run through set up and operation with a few examples.

Hardware setup

First you’ll need to solder some sort of connection to the module – such as 2×5 header pins. This makes it easy to wire it up to a breadboard or a ribbon cable:

The rest of the circuitry is straight-forward. There are ten pins in two rows of five, and with the display horizontal and the pins on the right, they are numbered as such:

Now make the following connections:

  • LCD pin 1 to 5V
  • LCD pin 2 to GND
  • LCD pin 3 to Arduino D4
  • LCD pin 4 to Arduino D5
  • LCD pin 5 to Arduino D6
  • LCD pin 6 to Arduino D7
  • LCD pin 7 – not connected
  • LCD pin 8 – Arduino D8
  • LCD pin 9 to the centre pin of a 10k trimpot – whose other legs connect to 5V and GND. This is used to adjust the contrast of the LCD.

The Arduino digital pins that are used can be changed – they are defined in the header file (see further on). If you were curious as to how low-current these modules are:

That’s 0.689 mA- not bad at all. Great for battery-powered operations. Now that you’ve got the module wired up, let’s get going with some demonstration sketches.

Software setup

The sketches used in this tutorial are based on work by Jeff Albertson and Robert Mech, so kudos to them – however we’ve simplified them a little to make use easier. We’ll just cover the functions required to display data on the LCD. However feel free to review the sketches and files along with the controller chip datasheet as you’ll get an idea of how the controller is driven by the Arduino.

When using the LCD module you’ll need a header file in the same folder as your sketch. You can download the header file from here. Then every time you open a sketch that uses the header file, it should appear in a tab next to the main sketch, for example:

headerinuse

There’s also a group of functions and lines required in your sketch. We’ll run through those now – so download the first example sketch, add the header file and upload it. Your results should be the same as the video below:

So how did that work? Take a look at the sketch you uploaded.  You need all the functions between the two lines of “////////////////////////” and also the five lines in void setup(). Then you can display a string of text or numbers using

which was used in void loop(). You can use the digits 0~9, the alphabet (well, what you can do with 7-segments), the degrees symbol (use an asterix – “*”) and a dash (use  – “-“). So if your sketch can put together the data to display in a string, then that’s taken care of.

If you want to clear the screen, use:

Next – to individually place digits on the screen, use the function:

Where n is the number to be displayed (zero or a positive integer), p is the position on the LCD for the number’s  (the positions from left to right are 11 to 0…), d is the number of digits to the right of the decimal point (leave as zero if you don’t want a decimal point), and l is the number of digits being displayed for n. When you display digits using this function you can use more than one function to compose the number to be displayed – as this function doesn’t clear the screen.

To help get your head around it, the following example sketch (download) has a variety of examples in void loop(). You can watch this example in the following video:

Conclusion

So there you have it – an incredibly inexpensive and possibly useful LCD module. Thank you to Jeff Albertson and Robert Mech for their help and original code.

LEDborder

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The following two tabs change content below.

John Boxall

Person. Author of http://arduinoworkshop.com Director of http://tronixlabs.com.au Rare updater of http://tronixstuff.com VK3FJBX

10 Responses to “Arduino and KTM-S1201 LCD modules”

  1. charting says:

    I purchased one of these a few months back on ebay (I paid more than a dollar), finally got a new soldering iron last week, saw this article today. As soon as I got off work, I hooked the display to my Aurduino Mega2560. Works as advertised. Thanks!

  2. Jeff Albertson says:

    Great Tutorial!
    I am Impressed!
    Thanks for the mention.
    Jeff Albertson

  3. Rick Chernenkoff says:

    Gentlemen : The videos look great ! I tried to download the sketches and H file to no avail . A bad link in there perhaps . I will try later .
    I would love to get this information as I have a bunch of these guys that I bought a couple of years ago and could never figure out how to get them running . A ” 10 pack ” of these were around $ 8 CDN from Electronics Goldmine in the USA .

  4. Hansibull says:

    Is it possible to modify the ktmPrnNumb() function, so I can write something like
    ktmPrnNumb(analogRead(A0)); and the display will show the digits correctly at the left or right side of the LCD?

  5. I bought some of these displays and I was able to get them to work with a Microchip PIC16F684. The project files are available for download at:
    http://enginuitysystems.com/files/Display.zip

    I had to make some fairly major changes to the code and not everything is implemented (such as conversion to uppercase), but it is similar enough to see what I’ve done.

    I’m using the Microchip MPLABX IDE with XC8 compiler.

  6. George Gardner says:

    This is great stuff, John! I was getting strange behavior and characters when printing a string (ktmwritestring) after a number has printed (ktmprnnumb).

    After about an hour of looking at the code, and I’m no expert by any means, it seems as though there may need to be a ktmshiftOut(_NoDecode) after a number has printed. There is one, but it is only executed ONLY IF there is a decimal > 0.

    I’m doing all this with an attiny84 too, so that may have something to do with it as well. Either way, I thought I’d post in case anyone else is having this issue.

    Again, thanks for sharing this awesome information! Keep it up!

Trackbacks/Pingbacks


Leave a Reply to John Boxall

Subscribe via email

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: