Archive | part review

Tutorial – Arduino and the MAX7219 LED Display Driver IC

Use the Maxim MAX7219 LED display driver with Arduino in Chapter 56 of our Arduino Tutorials. The first chapter is here, the complete series is detailed here.


Sooner or later Arduino enthusiasts and beginners alike will come across the MAX7219 IC. And for good reason, it’s a simple and somewhat inexpensive method of controlling 64 LEDs in either matrix or numeric display form. Furthermore they can be chained together to control two or more units for even more LEDs. Overall – they’re a lot of fun and can also be quite useful, so let’s get started.

Here’s an example of a MAX7219 and another IC which is a functional equivalent, the AS1107 from Austria Microsystems. You might not see the AS1107 around much, but it can be cheaper – so don’t be afraid to use that instead:

MAX7219 AS1107

 At first glance you may think that it takes a lot of real estate, but it saves some as well. As mentioned earlier, the MAX7219 can completely control 64 individual LEDs – including maintaining equal brightness, and allowing you to adjust the brightness of the LEDs either with hardware or software (or both). It can refresh the LEDs at around 800 Hz, so no more flickering, uneven LED displays.

You can even switch the display off for power saving mode, and still send it data while it is off. And another good thing – when powered up, it keeps the LEDs off, so no wacky displays for the first seconds of operation. For more technical information, here is the data sheet: MAX7219.pdf. Now to put it to work for us – we’ll demonstrate using one or more 8 x 8 LED matrix displays, as well as 8 digits of 7-segment LED numbers.

Before continuing, download and install the LedControl Arduino library as it is essential for using the MAX7219.

Controlling LED matrix displays with the MAX7219

First of all, let’s examine the hardware side of things. Here is the pinout diagram for the MAX7219:

MAX7219 pinout

The MAX7219 drives eight LEDs at a time, and by rapidly switching banks of eight your eyes don’t see the changes. Wiring up a matrix is very simple – if you have a common matrix with the following schematic:

LED matrix pinoutsconnect the MAX7219 pins labelled DP, A~F to the row pins respectively, and the MAX7219 pins labelled DIG0~7 to the column pins respectively. A total example circuit with the above matrix  is as follows:

MAX7219 example LED matrix circuit

The circuit is quite straight forward, except we have a resistor between 5V and MAX7219 pin 18. The MAX7219 is a constant-current LED driver, and the value of the resistor is used to set the current flow to the LEDs. Have a look at table eleven on page eleven of the data sheet:

MAX7219 resistor tableYou’ll need to know the voltage and forward current for your LED matrix or numeric display, then match the value on the table. E.g. if you have a 2V 20 mA LED, your resistor value will be 28kΩ (the values are in kΩ). Finally, the MAX7219 serial in, load and clock pins will go to Arduino digital pins which are specified in the sketch. We’ll get to that in the moment, but before that let’s return to the matrix modules.

In the last few months there has been a proliferation of inexpensive kits that contain a MAX7219 or equivalent, and an LED matrix. These are great for experimenting with and can save you a lot of work – some examples of which are shown below:

MAX7219 LED matrix modules

At the top is an example from, and the pair on the bottom are the units from a recent kit review. We’ll use these for our demonstrations as well.

Now for the sketch. You need the following two lines at the beginning of the sketch:

The first pulls in the library, and the second line sets up an instance to control. The four parameters are as follows:

  1. the digital pin connected to pin 1 of the MAX7219 (“data in”)
  2. the digital pin connected to pin 13 of the MAX7219 (“CLK or clock”)
  3. the digital pin connected to pin 12 of the MAX7219 (“LOAD”)
  4. The number of MAX7219s connected.

If you have more than one MAX7219, connect the DOUT (“data out”) pin of the first MAX7219 to pin 1 of the second, and so on. However the CLK and LOAD pins are all connected in parallel and then back to the Arduino.

Next, two more vital functions that you’d normally put in void setup():

The first line above turns the LEDs connected to the MAX7219 on. If you set TRUE, you can send data to the MAX7219 but the LEDs will stay off. The second line adjusts the brightness of the LEDs in sixteen stages. For both of those functions (and all others from the LedControl) the first parameter is the number of the MAX7219 connected. If you have one, the parameter is zero… for two MAX7219s, it’s 1 and so on.

Finally, to turn an individual LED in the matrix on or off, use:

which turns on an LED positioned at col, row connected to MAX7219 #1. Change TRUE to FALSE to turn it off. These functions are demonstrated in the following sketch:

And a quick video of the results:

How about controlling two MAX7219s? Or more? The hardware modifications are easy – connect the serial data out pin from your first MAX7219 to the data in pin on the second (and so on), and the LOAD and CLOCK pins from the first MAX7219 connect to the second (and so on). You will of course still need the 5V, GND, resistor, capacitors etc. for the second and subsequent MAX7219.

You will also need to make a few changes in your sketch. The first is to tell it how many MAX7219s you’re using in the following line:

by replacing X with the quantity. Then whenever you’re using  a MAX7219 function, replace the (previously used) zero with the number of the MAX7219 you wish to address. They are numbered from zero upwards, with the MAX7219 directly connected to the Arduino as unit zero, then one etc. To demonstrate this, we replicate the previous example but with two MAX7219s:

And again, a quick demonstration:

Another fun use of the MAX7219 and LED matrices is to display scrolling text. For the case of simplicity we’ll use the LedControl library and the two LED matrix modules from the previous examples.

First our example sketch – it is quite long however most of this is due to defining the characters for each letter of the alphabet and so on. We’ll explain it at the other end!

The pertinent parts are at the top of the sketch – the following line sets the number of MAX7219s in the hardware:

The following can be adjusted to change the speed of text scrolling:

… then place the text to scroll in the following (for example):

Finally – to scroll the text on demand, use the following:

You can then incorporate the code into your own sketches. And a video of the example sketch in action:

Although we used the LedControl library, there are many others out there for scrolling text. One interesting example is Parola  – which is incredibly customisable.

Controlling LED numeric displays with the MAX7219

Using the MAX7219 and the LedControl library you can also drive numeric LED displays – up to eight digits from the one MAX7219. This gives you the ability to make various numeric displays that are clear to read and easy to control. When shopping around for numeric LED displays, make sure you have the common-cathode type.

Connecting numeric displays is quite simple, consider the following schematic which should appear familiar by now:

MAX7219 7-segment schematic

The schematic shows the connections for modules or groups of up to eight digits. Each digit’s A~F and dp (decimal point) anodes connect together to the MAX7219, and each digit’s cathode connects in order as well. The MAX7219 will display each digit in turn by using one cathode at a time. Of course if you want more than eight digits, connect another MAX7219 just as we did with the LED matrices previously.

The required code in the sketch is identical to the LED matrix code, however to display individual digits we use:

where A is the MAX7219 we’re using, B is the digit to use (from a possible 0 to 7), C is the digit to display (0~9… if you use 10~15 it will display A~F respectively) and D is false/true (digit on or off). You can also send basic characters such as a dash “-” with the following:

Now let’s put together an example of eight digits:

and the sketch in action:


We have only scratched the surface of what is possible with the MAX7219 and compatible parts. They’re loads of fun and quite useful as well. And finally a plug for our own store – – which along with being Australia’s #1 Adafruit distributor, also offers a growing range and Australia’s best value for supported hobbyist electronics from DFRobot, Freetronics, Seeedstudio and much much more.


Posted in arduino, as1107, COM-09622, LED matrix, lesson, max7219, part review, tronixlabs, tronixstuff, tutorial

Part review – Freetronics HBRIDGE motor driver shield for Arduino


Controlling motors with an Arduino is a fun and generally integral part of the learning process for most up-and-coming embedded electronics enthusiasts. Or quite simply, using motors is fun ’cause you can make robots, tanks and stuff that moves. And thanks to Freetronics we have their new HBRIDGE motor shield for Arduino to review, so let’s check it out and get some things moving with it.

Arriving in retail-friendly packaging, the HBRIDGE can be stored with the included reusable packaging, and also has a quick-start guide that explains the technical specifications and URLs for tutorials:


The shield is compatible with the latest R3-series Arduino boards including the Leonardo and of course the Freetronics Eleven board:

HBRIDGE shield Freetronics Eleven


The HBRIDGE shield is based on the Allegro A4954 Dual Full-Bridge DMOS PWM Motor Driver. For the curious, you can download the data sheet (pdf). This allows very simple control of two DC motors with a maximum rating of 40V at 2A, or one bipolar stepper motor. Unlike other motor shields I’ve seen, the HBRIDGE has a jumper which allows the power supply for the motor shield to be fed into the Arduino’s Vin line – so if your motor power supply is under 12V DC you can also power the Arduino from the same supply. Or you can run the motors from the Arduino’s power supply – if you’re sure that you won’t exceed the current rating. Frankly the former would be a safer and this the preferable solution.

The motor(s) are controlled very simply via PWM and digital logic. You feed the A4954 a PWM signal from a digital output pin for motor speed, and also set two inputs with a combination of high/low to set the motor direction, and also put the motor controlled into coast or brake mode. However don’t panic, it’s really easy.

Using the shield

How easy? Let’s start with two DC motors. One example of this is the tank chassis used in Chapter 12 of my book “Arduino Workshop – A Hands-On Introduction with 65 Projects“:


The chassis is pretty much a standard tank chassis with two DC motors that run from an internal 9V battery pack. Search the Internet for “Dagu Rover 5” for something similar. Connection is a simple manner of feeding the power lines from the battery and the motor wires into the terminal block on the HBRIDGE shield.

Next, take note of two things. First – the slide switches below the jumpers. Using these you can select the maximum amount of current allowed to flow from the power supply to each motor. These can be handy to ensure your motor doesn’t burn out by drawing too much current in a stall situation, so you can set these to the appropriate setting for your motor – or if you’re happy there won’t be any issues just leave them both on 2A.

The second thing to note is the six jumpers above the switches. These control which digital pins on your Arduino are used to control the motor driver. Each motor channel requires two outputs and one PWM output. If you leave them all on, the Arduino pins used will be the ones listed next to each jumper, otherwise remove the jumpers and manually wire to the required output. For the purposes of our demonstration, we’ll leave all the jumpers in. A final word of warning is to be careful not to touch the A4954 controller IC after some use – it can become really hot … around 160 degrees Celsius. It’s the circled part in the image below:


So back to the DC motors. You have two digital outputs to set, and also a PWM signal to generate – for each channel. If you set the outputs to 1 and 0  – the motor spins in one direction. Use 0 and 1 to spin the other way. And the value of the PWM (0~255) determines the speed. So consider the following sketch:

Instead of chasing the tank chassis with a camera, here it is on the bench:

Now to try out a stepper motor. You can control a bipolar motor with the HBRIDGE shield, and each coil (pole) is connected to a motor channel.

Hint – if you’re looking for a cheap source of stepper motors, check out discarded office equipment such as printers or photocopiers. 

For the demonstration, I’ve found a random stepper motor from a second-hand store and wired up each pole to a channel on the HBRIDGE shield – then run the Arduino stepper motor demonstration sketch by Tom Igoe:

With the following results:

Considering it was a random stepper motor for which we didn’t have the specifications for – it’s always nice to have it work the first time! For more formal situations, ensure your stepper motor matches the power supply voltage and so on. Nevertheless it shows how easy it can be to control something that appears complex to some people, so enjoy experimenting with them if you can.


Thanks to Freetronics we have a shield to give away to one lucky participant. To enter, clearly print your email address on the back of a postcard and mail it to:

H-Bridge Competition, PO Box 5435 Clayton 3168 Australia.

Entries must be received by the 20th of  September 2013. One postcard will then be drawn at random, and the winner will receive one H-Bridge shield delivered by Australia Post standard air mail. One entry per person – duplicates will be destroyed. We’re not responsible for customs or import duties, VAT, GST, import duty, postage delays, non-delivery or whatever walls your country puts up against receiving inbound mail.


As demonstrated, the HBRIDGE shield “just works” – which is what you need when bringing motorised project ideas to life. The ability to limit current flow and also power the host board from the external supply is a great idea, and with the extra prototyping space on the shield you can also add extra circuitry without needing another protoshield. Very well done. For more information and to order, visit the Freetronics website. Full-sized images are on flickr. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.


In the meanwhile have fun and keep checking into 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.

Note – The motor shield used in this article was a promotional consideration supplied by Freetronics.

Posted in A4954, freetronics, HBRIDGE, part review, review, stepper motor, tronixstuff, tutorial2 Comments

Tutorial – 74HC4067 16-Channel Analog Multiplexer Demultiplexer


Now and again there’s a need to expand the I/O capabilities of your chosen micorocontroller, and instead of upgrading you can often use external parts to help solve the problem. One example of this is the 74HC4067 16-channel analog multiplexer demultiplexer. That’s a mouthful – however in simple form it’s an IC that can direct a flow of current in either direction from one pin  to any one of sixteen pins. Another way to think abou it is that you can consider the 74HC4067 to be a digital replacement to those rotary switches that allow you to select one of sixteen positions.

Here’s an example of the SMD version:


Don’t let that put you off, it’s just what we had in stock at the time. The part itself is available in through-hole and surface mount versions.

Using the 74HC4067

At this point you should download the data sheet, as we refer to it through the course of the article. The first thing to note is that the 74HC4067 can operate on voltages between 2 and 6V DC, which allows use with 3.3V and 5V microcontrollers and boards such as Arduino and Raspberry Pi. If for some reason you have the 74HCT4067 it can only work on 4.5~5.5V DC.  Next – consider the pinout diagram from the data sheet:

74HC4067 pinoutThe power supply for the part is applied to pin 24, and GND to … pin 12. Pin 15 is used to turn the control the current flow through the inputs/outputs – if this is connected to Vcc the IC stops flow, and when connected to GND it allows flow. You can always control this with a digital output pin if required, or just tie it to GND if this doesn’t matter.

Next – pin one. This is where the current either flows in to be sent to one of the sixteen outputs – or where the current flows out from one of the sixteen inputs. The sixteen inputs/outputs are labelled I0~I15. Finally there are the four control pins – labelled S0~S3. By setting these HIGH or LOW (Vcc or GND) you can control which I/O pins the current flow is directed through. So how does that work? Once again – reach for the the data sheet and review the following table:

74HC4067 truth tableNot only does it show what happens when pin 15 is set to HIGH (i.e. nothing) it shows what combination of HIGH and LOW for the control pins are required to select which I/O pin the current will flow through. If you scroll down a bit hopefully you noticed that the combination of S0~S3 is in fact the binary equivalent of the pin number – with the least significant bit first. For example, to select pin 9 (9 in binary is 1001) you set the IC pins S0 and S3 to HIGH, and S1 and S2 to LOW. How you control those control pins is of course up to you – either with some digital logic circuit for your application or as mentioned earlier with a microcontroller.


Apart from the power supply requirements, there are a few limitations to keep in mind. Open you data sheet and consider the “DC Electrical Specifications” table. The first two parameters show what the minimum voltage that can be considered as a HIGH and the maximum for a LOW depending on your supply voltage. The next item of interest is the “ON” resistance – that is the resistance in Ohms (Ω) between one of the sixteen inputs/outputs and the common pin. When a channel is active, and a 5V supply voltage, we measured a resistance of 56Ω without a load through that channel – and the data sheet shows other values depending on the current load and supply voltage. Finally, don’t try and run more than 25 mA of current through a pin.


Now to show an example of both multiplexing and demultiplexing. For demonstration purposes we’re using an Arduino Uno-compatible board with the 74HC4067 running from a 5V supply voltage. Pin 15 of the ‘4067 is set to GND, and control pins S0~S3 are connected to Arduino digital output pins D7~D4 respectively.


This is where we select one input pin of sixteen and allow current to flow through to the common pin (1). In this example we connect the common pin to the board’s analog input pin – so this can be used as a method of reading sixteen analog signals (one at a time) using only one ADC. When doing so – take note of the limitations mentioned earlier – take some resistance measurements in your situation to determine what the maximum value will be from your ADC and calibrate code accordingly.

With both of the examples we’ll use port manipulation to control the digital pins which are connected to the 74HC4067’s control pins. We do this as it reduces the code required and conceptually I feel it’s easier. For example – to select I/O 15 you need to turn on all the control pins – so you just have to set Arduino PORTD to B11110000 (which is binary 15 LSB first) and much neater than using four digitalWrite() functions.

In the following example sketch, you can see how we’ve put the binary values for each control possibility in the array byte controlPins[] – which is then used to set the pins easily in void loop().

This simply sets each input pin in turn, then reads the ADC value into an array – whose values are then sent to the serial monitor:

… and a quick video of the results:


Now for the opposite function – sending current from the common pin to one of sixteen outputs. A fast example of this is by controlling one of sixteen LEDs each connected to an output pin, and with 5V on the 74HC4067 common pin. We don’t need current-limiting resistors for the LEDs due to the internal resistance in the 74HC4067. Here’s the sketch:

… and the LEDs in action:


If you’re considering the 74HC4067 or hadn’t known about it previously, we hope you found this of interest. If you have any questions please leave them below or privately via the contact page. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into 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.


Posted in 74HC4067, arduino, Demultiplexer, Multiplexer, part review, review, tronixstuff, tutorial13 Comments

Book – “Arduino Workshop – A Hands-On Introduction with 65 Projects”

Over the last few years I’ve been writing a few Arduino tutorials, and during this time many people have mentioned that I should write a book. And now thanks to the team from No Starch Press this recommendation has morphed into my new book – “Arduino Workshop“:


Although there are seemingly endless Arduino tutorials and articles on the Internet, Arduino Workshop offers a nicely edited and curated path for the beginner to learn from and have fun. It’s a hands-on introduction to Arduino with 65 projects – from simple LED use right through to RFID, Internet connection, working with cellular communications, and much more.

Each project is explained in detail, explaining how the hardware an Arduino code works together. The reader doesn’t need any expensive tools or workspaces, and all the parts used are available from almost any electronics retailer. Furthermore all of the projects can be finished without soldering, so it’s safe for readers of all ages.

The editing team and myself have worked hard to make the book perfect for those without any electronics or Arduino experience at all, and it makes a great gift for someone to get them started. After working through the 65 projects the reader will have gained enough knowledge and confidence to create many things – and to continue researching on their own. Or if you’ve been enjoying the results of my thousands of hours of work here at tronixstuff, you can show your appreciation by ordering a copy for yourself or as a gift 🙂

You can review the table of contents, index and download a sample chapter from the Arduino Workshop website.

Arduino Workshop is available from No Starch Press in printed or ebook (PDF, Mobi, and ePub) formats. Ebooks are also included with the printed orders so you can get started immediately.


In the meanwhile have fun and keep checking into 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.

Posted in arduino, Arduino Workshop, book, books, cellular, clocks, display, distance, ds1307, DS3232, education, EEPROM, freetronics, GPS, graphic, GSM, hardware hacking, I2C, internet, LCD, learning electronics, lesson, no starch press, numeric keypad, part review, product review, projects, RDM630, RDM6300, relay, review, sensor, servo, SMS, time clock, timing, tronixstuff, tutorial, twitter, wireless, xbee13 Comments

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.


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:


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:


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.


In the meanwhile have fun and keep checking into 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.

Posted in arduino, display, education, ktm-s101, ktms101, LCD, lesson, part review, pd7225, tutorial10 Comments

mbed and the Freescale FRDM-KL25Z development board

In this article we examine the mbed rapid prototyping platform with the Freescale FRDM-KL25Z ARM® Cortex™-M0+ development board.


A while ago we looked at the mbed rapid prototyping environment for microcontrollers with the cloud-based IDE and the NXP LPC1768 development board, and to be honest we left it at that as I wasn’t a fan of cloud-based IDEs. Nevertheless, over the last two or so years the mbed platform has grown and developed well – however without too much news on the hardware side of things. Which was a pity as the matching development boards usually retailed for around $50 … and most likely half the reason why mbed didn’t become as popular as other rapid development platforms.

And now we have another powerful yet inexpensive board to use with mbed  – the Freescale FRDM-KL25Z

It’s a move in the right direction for both mbed and Freescale. It allows educators and interested persons access to a very user-friendly IDE and dirt-cheap development boards.

What is mbed anyway?

mbed is a completely online development environment. That is, in a manner very similar to cloud computing services such as Google Docs or Zoho Office. However there are some pros and cons of this method. The pros include not having to install any software on the PC – as long as you have a web browser and a USB port you should be fine; any new libraries or IDE updates are handled on the server leaving you to not worry about staying up to date; and the online environment can monitor and update your MCU firmware if necessary. However the cons are that you cannot work with your code off-line, and there may be some possible privacy issues. Here’s an example of the environment:


As you can see the IDE is quite straight-forward. All your projects can be found on the left column, the editor in the main window and compiler and other messages in the bottom window. There’s also an online support forum, an official mbed library and user-submitted library database, help files and so on – so there’s plenty of support. Code is written in C/C++ style and doesn’t present any major hurdles. When it comes time to run the code, the online compiler creates a downloadable binary file which is copied over to the hardware via USB.

And what’s a Freedom board?

It’s a very inexpensive development board based on the Freescale ARM® Cortex™-M0+ MKL25Z128VLK4 microcontroller.

Features include  (from the product website):

  • MKL25Z128VLK4 MCU – 48 MHz, 128 KB flash, 16 KB SRAM, USB OTG (FS), 80LQFP
  • Capacitive touch “slider,” MMA8451Q accelerometer, tri-color LED
  • Easy access to MCU I/O
  • Sophisticated OpenSDA debug interface
  • Mass storage device flash programming interface (default) – no tool installation required to evaluate demo apps
  • P&E Multilink interface provides run-control debugging and compatibility with IDE tools
  • Open-source data logging application provides an example for customer, partner and enthusiast development on the OpenSDA circuit

And here it is:


In a lot of literature about the board it’s mentioned as being “Arduino compatible”. This is due to the layout of the GPIO pins – so if you have a 3.3 V-compatible Arduino shield you may be able to use it – but note that the I/O pins can only sink or source 3 mA (from what I can tell) – so be careful with the GPIO . However on a positive side the board has the accelerometer and an RGB LED which are handy for various uses.

Getting started

Now we”ll run through the process of getting a Freedom board working with mbed and creating a first program. You’ll need a computer (any OS) with USB, an Internet connection and a web browser, a USB cable (mini-A to A) and a Freedom board. The procedure is simple:

  1. Order your board from
  2. Download and install the USB drivers for Windows or Linux from here.
  3. Visit and create a user account. Check your email for the confirmation link and follow the instructions within.
  4. Plug in your Freedom board – using the USB socket labelled “OpenSDA”. It will appear as a disk called “bootloader”
  5. Download this file and copy it onto the “bootloader” drive
  6. Unplug the Freedom board, wait a moment – then plug it back in. It should now appear as a disk called “MBED”, for example :


There will be a file called ‘mbed’ on the mbed drive – double-click this to open it in a web browser. This process activates the board on your mbed account – as shown below:


Now you’re ready to write your code and upload it to the Freedom board. Click “Compiler” at the top-right to enter the IDE.

Creating and uploading code

Now to create a simple program to check all is well. When you entered the IDE in the previous step, it should have presented you with the “Guide to mbed Online Compiler”. Have a read, then click “New” at the top left. Give your program a name and click OK. You will then be presented with a basic “hello world” program that blinks the blue LED in the RGB module. Adjust the delays to your liking then click “Compile” in the toolbar.

If all is well, your web browser will present you with a .bin file that has been downloaded to the default download directory. (If not, see the error messages in the area below the editor pane). Now copy this .bin file to the mbed drive, then press the reset button (between the USB sockets) on the Freedom board. Your blue LED should now be blinking.

Moving forward

You can find some code examples that demonstrate the use of the accelerometer, RGB LED and touch sensor here. Here’s a quick video of the touch sensor in action:

So which pin is what on the Freedom board with respect to the mbed IDE? Review the following map:


All the pins in blue – such as PTxx can be referred to in your code. For example, to pulse PTA13 on and off every second, use:

The pin reference is inserted in the DigitalOut assignment and thus “pulsepin” refers to PTA13. If you don’t have the map handy, just turn the board over for a quick-reference:


Just add “PT” to the pin number. Note that the LEDs are connected to existing GPIO pins: green – PTB19, red – PTB18 and blue – PTB.

Where to from here? 

It’s up to you. Review the Freedom board manual (from here) and the documentation on the mbed website, create new things and possibly share them with others via the mbed environment. For more technical details review the MCU data sheet. And to order your own Freedom board, visit


The Freedom board offers a very low cost way to get into microcontrollers and programming. You don’t have to worry about IDE or firmware revisions, installing software on locked-down computers, or losing files. You could teach a classroom full of children embedded programming for around $20 a head (a board and some basic components). Hopefully this short tutorial was of interest. We haven’t explored every minute detail – but you now have the basic understanding to move forward with your own explorations.


Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – 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.

Posted in 1 hz, arm cortex, education, FRDM-KL25Z, freedom, freescale, lesson, M0+, mbed, MKL25Z128VLK4, MMA8451Q, opensda, part review, tronixlabs, tronixstuff, tutorial0 Comments

First look: Arduino Due

Updated 27/02/2013


After much waiting the Arduino Due has been released, so let’s check it out. We’ll run through the specifications and some areas of interest, see what’s different, some random notes – then try out some of the new features. Before moving forward note that it might look the same – the Due is not a drop-in replacement for older boards – even the Mega2560. It’s different.

First announced in late 2011, the Due is the Arduino team’s first board with a 32-bit processor – the Atmel SAM3X8E ARM Cortex-M3 CPU. With an 84 Mhz CPU speed and a host of interfaces and I/O, this promises to be the fastest and most functional Arduino board ever. According to the official Arduino press release:

Arduino Due is ideal for those who want to build projects that require high computing power such as the remotely-controlled drones that, in order to fly, need to process a lot of sensor data per second.
Arduino Due gives students the opportunity to learn the inner workings of the ARM processor in a cheaper and much simpler way than before.
To Scientific projects, which need to acquire data quickly and accurately, Arduino Due provides a platform to create open source tools that are much more advanced than those available now.
The new platform enables the open source digital fabrication community (3d Printers, Laser cutters, CNC milling machines) to achieve higher resolutions and faster speed with fewer components than in the past.

Sounds good – and the Due has been a long time coming, so let’s hope it is worth the wait. The SAM3X CPU holds a lot of promise for more complex projects that weren’t possible with previous ATmega CPUs, so this can be only a good thing.


First of all, here’s the Due in detail – top and bottom (click to enlarge):

You can use Mega-sized protoshields without any problem (however older shields may miss out on the upper I2C pins) – they’ll physically fit in … however their contents will be a different story:

The specifications of the Due are as follows (from Arduino website):

Microcontroller AT91SAM3X8E
Operating Voltage 3.3V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 54 (of which 12 provide PWM output)
Analog Input Pins 12
Analog Outputs Pins 2 (DAC)
Total DC Output Current on all I/O lines 130 mA
DC Current for 3.3V Pin 800 mA
DC Current for 5V Pin 800 mA
Flash Memory 512 KB all available for the user applications
SRAM 96 KB (two banks: 64KB and 32KB)
Clock Speed 84 MHz

Right away a few things should stand out – the first being the operating voltage – 3.3V. That means all your I/O needs to work with 3.3V – not 5V. Don’t feed 5V logic line into a digital input pin and hope it will work – you’ll damage the board. Instead, get yourself some logic level converters. However there is an IOREF pin like other Arduino boards which intelligent shields can read to determine the board voltage. The total output current for all I/O lines is also 130 mA … so no more sourcing 20mA from a digital ouput for those bright LEDs.

The power regulator for 5V has been changed from linear to switching – so no more directly inserting 5V into the 5V pin. However the 3.3V is through an LDO from 5v.

Each digital I/O pin can source 3 or 15 mA – or sink 6 or 9 mA … depending on the pin. High-current pins are CAN-TX, digital 1, 3~12, 23~51, and SDA1. The rest are low current. And there’s still an LED on digital 13. You will need to redesign any existing projects or shields if moving to the Due.

The analogue inputs now have a greater resolution – 12-bits. That means it can return a value of  0~4095 representing 0~3.3V DC. To activate this higher resolution you need to use the function analogReadResolution(12).

Memory – there isn’t any EEPROM in the SAM3X – so you’ll need external EEPROMs to take care of more permanent storage. However there’s 512 KB of flash memory for sketches – which is huge. You have to see it to believe it:

Excellent. A new feature is the onboard erase button. Press it for three seconds and it wipes out the sketch. The traditional serial line is still digital 0/1 – which connect to the USB controller chip.

Hardware serial – there’s four serial lines. Pulse-width modulation (PWM) is still 8-bit and on digital pins 2~13.

The SPI bus is on the ICSP header pins to the right of the microcontroller – so existing shields that use SPI will need to be modified – or experiment with a LeoShield:

You can also use the extended SPI function of the SAM3X which allow the use of digital pins 4, 10 or 52 for CS (chip select).

The SAM3X supports the automtive CAN bus, and the pins have been brought out onto the stacked header connectors – however this isn’t supported yet in the IDE.

There are two I2C buses – located on digital 20/21 and the second is next to AREF just like on the Leonardo.

There’s a 10-pin JTAG mini-header on the Due, debug pins and a second ICSP for the ATmega16U2 which takes care of USB. Speaking of USB – there’s two microUSB sockets. One is for regular programming via the Arduino IDE and the USB interface, the other is a direct native USB programming port direct to the SAM3X.

The SAM3X natively supports Ethernet, but this hasn’t been implemented on the hardware side for the Due. However some people in the Arduino forum might have a way around that.

Using the Due

First of all – at the time of writing – you need to install Arduino IDE v1.5.1 release 2 – a beta version. Windows users – don’t forget the USB drivers. As always, backup your existing installation and sketch files somewhere safe – and you can run more than one IDE on the same machine.

When it comes time to upload your sketches, plug the USB cable into the lower socket on the Due – and select Arduino Due (Programming Port) from the Tools>Board menu in the IDE.

Let’s upload a sketch now (download) – written by Steve Curd from the Arduino forum. It calculates Newton Approximation for pi using an infinite series. As you can see from the results below, the Due is much faster (690 ms) than the Mega2560 (5765 ms):



Next, let’s give the digital-to-analogue converters a test. Finally we have two, real, 12-bit DACs with the output pins being … DAC0 and DAC1. No more mucking about with external R-C filters to get some audio happening. These pins provides true analogue outputs which is controlled by the analogWrite() function. To use them is very simple – consider the following example sketch which creates a triangle wave:

And the results from the DSO:

This opens up all sorts of audio possibilities. With appropriate wavetable data saved in memory you could create various effects. However the DAC doesn’t give a full 0~3.3V output – instead it’s 1/6 to 5/6 of the Aref voltage. With the IDE there are example sketches that can play a .wav file from an SDcard – however I’d still be more inclined to use an external shield for that. Nevertheless for more information, have a look at the Audio library. Furthermore, take heed of the user experiences noted in the Arduino forum – it’s very easy to destroy your DAC outputs. In the future we look forward to experimenting further with the Due – so stay tuned.

Getting a Due

Good luck … at the time of writing – the Dues seem to be very thin on the ground. This may partly be due to the limited availability of the Atmel SAM3X8E. My contacts in various suppliers say volumes are quite limited.


I really hope this is a rare event, however one of the Dues received had the following fault in manufacturing:

One side of the crystal capacitor wasn’t in contact with the PCB. However this was a simple fix. How the QC people missed this … I don’t know. However I’ve seen a few Arduinos of various types, and this error is not indicative of the general quality of Arduino products.

Where to from here?

Visit the official Arduino Due page, the Due discussion section of the Arduino forum, and check out the reference guide for changes to functions that are affected by the different hardware.


Well that’s my first take on the Due – powerful and different. You will need to redesign existing projects, or build new projects around it. And a lot of stuff on the software side is still in beta. So review the Due forum before making any decisions. With that in mind – from a hardware perspective – it’s a great step-up from the Mega2560.

So if you’re interested – get one and take it for a spin, it won’t disappoint. The software will mature over time which will make life easier as well. If you have any questions (apart from Arduino vs. Raspberry Pi) leave a comment and we’ll look into it.


Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our 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.

Posted in arduino, arm cortex, AT91SAM3X8E, dev-11589, due, part review, review, SAM3X8E, tutorial6 Comments

Kit Review – akafugu TWILCD Display Controller Backpacks


Working with LCD displays is always useful, for debugging hardware by showing various data or part of a final design. Furthermore, using them can be rather wasteful of I/O pins, especially when trying to squeeze in other functionality. Plus there’s the external contrast adjustment, general wiring and the time taken to get it working. (Don’t believe me? See here).

However, using the subjects of this kit review – you can convert standard HD44780 LCD modules to use the I2C bus using a small backpack-style board – bringing total I/O down to four wires – 5V/3.3V, GND, SDA and SCL. If you’re using an Arduino – don’t panic if you’re not up on I2C – a software library takes care of the translation leaving you to use the LiquidCrystal functions as normal. Furthermore you can control the brightness and contrast (and colour for RGB modules) – this feature alone is just magic and will make building these features into projects much, much easier.

In this review we examine both of the backpacks available from akafugu. There are two available:

  • the TWILCD: Supports 1×16 and 2×7 connectors. It covers 16×1, 20×1, 16×2, 20×2 and 20×4 displays with and without backlight, and the
  • TWILCD 40×2/40×4/RGB: Supports 1×18 connector (for Newhaven RGB backlit displays), 2×8 connector (used for some 20×4 displays) and 2×9 connector (used for 40×4 displays)
If unsure about your LCD, see the list and explanation here. The LCDs used in this article were supplied with the mono and colour LCD bundles available from akafugu. So let’s see how easy they really are, and put them through their paces.


The backpacks arrive in the usual anti-static bags:

First we’ll examine the TWILCD board:

Very small indeed. There are three distinct areas of interface – including the single horizontal or dual vertical connectors for various LCDs, and I2C bus lines as well as ICSP connectors for the onboard ATTINY4313 microcontroller. The firmware can be updated and is available on the akafugu github repository. If you look at the horizontal row along the top – there are eighteen holes. This allows for displays that have pins ordered 1~16 and also those with 15,16,1~16 order (15 and 16 are for the LCD backlight).

The next step is to solder in the connectors for power and I2C if so desired, and then the LCD to the backpack. Double-check that you have the pin numbering and alignment correct before soldering, for example:

and then you’re finished:

Simple. Now apply power and after a moment the the backpack firmware will display the I2C bus address:

Success! Now let’s repeat this with the TWILCD 40×2/40×4/RGB version. The backpack itself is still quite small:

… and has various pin alignments for different types of LCD module. Note the extra pins allowing use of RGB-backlit modules and 40×4 character modules. Again,  make sure you have the pins lined up against your LCD module before soldering the backpack in:

 Notice how the I2C connector is between the LCD and the backpack – there is enough space for it to sit in there, and also acts as a perfect spacer when soldering the backpack to the display module.  Once finished soldering, apply 5/3.3V and GND to check your display:

Using the TWILCDs

Using the backpacks is very easy. If you aren’t using an Arduino, libraries for AVR-GCC are available. If you are using the Arduino system, it is very simple. Just download and install the library from here. Don’t forget to connect the SDA and SCL connectors to your Arduino. If you’re unsure about LCD and Arduino – see here.

Programming for the TWILCD is dead simple – just use your existing Arduino sketch, but replace


and that’s it. Even creating custom characters. No new functions to learn or tricks to take note of – they just work. Total win. The only new functions you will need are to control the brightness and contrast… to set the brightness, use:

You can also set the brightness level to EEPROM as a default using:

Contrast is equally simple, using:


You can see these in action using the example sketches with the Arduino library, and in the following video:

Now for the TWILCD 40×2/40×4/RGB version. You have one more function to set the colour of the text:

where red, green and blue are values between 0 and 254. Easily done. You can see this in action using the test_RGB example sketch included with the library, and shown in the following video:


The TWILCD backpacks are simple, easy to setup and easy to use. They make using LCD displays a lot easier and faster for rapid prototyping, experimenting or making final products easier to use and program. A well-deserved addition to every experimenter’s toolkit. For more information, visit the akafugu product website. Full-size images available on flickr.

Note – the products used in this article were a promotional consideration from, however the opinions stated are purely my own.

In the meanwhile have fun and keep checking into 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.

Translated version in Serbo-Croatian language.

Posted in akafugu, arduino, clocks, I2C, kit review, LCD, part review, rgb0 Comments

Arduino and TM1640 LED Display Modules


The purpose of this article is to demonstrate the use of the second (here’s the first) interesting LED display module I discovered on the dealextreme website, for example:

As you can see the display unit holds a total of sixteen seven-segment LED digits using four modules. However thanks to the use of the TM1640 controller IC

… the entire display is controlled with only four wires – 5V, GND, data in and clock:

Here is the data sheet for the TM1640. The board also ships with the 30cm long four-wire lead and fitted plug. Finally, there is a ‘power on’ LED on the right-hand end of the board:

Getting Started

Now to make things happen. From a hardware perspective – it couldn’t be easier. Connect the 5V and GND leads to … 5V and GND. The data and clock leads will connect to two Arduino digital pins. That’s it. The maximum current drawn by the display with all segments on is ~213mA:

So you should be able to drive this from a normal Arduino-compatible board without any hassle. Please note that the TM1640 IC does heat up somewhat, so you may want to consider some sort of heatsink if intending to max out the display in this manner.

From the software side of things you will need to download and install the TM1638 library (yes) which also handles the TM1640 chip. To simply display text from a string on the display, examine the following sketch:

Which will display:

The sixteen digit binary number in the module.setDisplayToString() line controls the decimal points – 0 for off and 1 for on. For example, changing it to

will display:

You can also display text in a somewhat readable form – using the characters available in this list. Displaying numbers is very easy, you can address each digit individually using:

where x is the digit, y is the position (0~15), and true/false is the decimal point. At this time you can’t just send a long integer down to the display, so you will need to either convert your numbers to a string or failing that, split it up into digits and display them one at a time.

In the following example sketch we display integers and unsigned integers by using the C command sprintf(). Note the use of %i to include an integer, and %u for unsigned integer:

And the resulting output:

Now you have an idea of what is possible, a variety of display options should spring to mind. For example:

Again, this display board was a random, successful find. When ordering from dealextreme, do so knowing that your order may take several weeks to arrive as they are not the fastest of online retailers; and your order may be coming from mainland China which can slow things down somewhat. Otherwise the module worked well and considering the minimal I/O and code requirements, is a very good deal.

Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our 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.

Posted in arduino, lesson, part review, TM1638, TM1640, tutorial10 Comments

Hewlett-Packard 5082-7415 LED Display from 1976

In this article we examine a five digit, seven-segment LED display from Hewlett-Packard, the 5082-7415:

According to the data sheet (HP 5082-series.pdf) and other research this was available for a period of time around 1976 and used with other 5082-series modules in other HP products. Such as the Hewlett-Packard 3x series of calculators, for example:

Using the display is very easy – kudos to the engineers at HP for making a simple design that could be reusable in many applications. The 5082-7415 is a common-cathode unit and wiring is very simple – there are the usual eight anodes for segments a~f and the decimal point, and the five cathodes.

As this module isn’t too easily replaceable, I was very conservative with the power supply – feeding just under 1.6V at 10mA to each of the anode pins. A quick test proved very promising:

Excellent – it worked! But now to get it displaying some sort of interesting way. Using the following hardware…

  • Freetronics Eleven Arduino-compatible board
  • Two 74HC595 shift registers
  • Eight 560 ohm resistors
  • Five 1k ohm resistors
  • Five BC548 transistors
  • A large solderless breadboard and plenty of wires

… it was connected in the same method as a four-digit display (except for the extra digit) as described in my tutorial. Don’t forget to use the data sheet (HP 5082-series.pdf). You don’t have to use Arduino – any microcontroller with the appropriate I/O can take care of this.

Here is a simple Arduino sketch that scrolls through the digits with and then without the decimal point:

And the results:

Now for something more useful. Here is a function that sends a single digit to a position on the display with the option of turning the decimal point on or off:

So if you wanted to display the number three in the fourth digit, with the decimal point – use

with the following result:

We make use of the displayDigit() function in our next sketch. We introduce a new function:

It accepts a long integer between zero and 99999 (number) and displays it on the module for cycles times:

For demonstration purposes the sketch displays random numbers, as shown in the video below:

Update – 01/10/2014

You can purchase the four-digit version (QDSP6064) from Tronixlabs:

They worked very nicely and can be driven in the same method as the 5082-7415s descibed earlier. In the following video we have run the same sketches with the new displays:

In the meanwhile, I hope you found this article of interest. Thanks to the Vintage Technology Association website and the Museum of HP Calculators for background information. And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.


Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

Posted in 5082-7415, arduino, hardware hacking, HP, LED, lesson, part review, tronixlabs, tutorial, vintage

Arduino and TM1638 LED Display Modules


The purpose of this article is to demonstrate the use of some interesting LED display modules I discovered on the dealextreme website, for example:

They contain eight 7-segment red LED digits, eight red/green LEDs and also eight buttons for user input. You can get red or green display models. The units can also be daisy-chained, allowing up to five at once, and a short cable is included with each module, as well as some short spacers and bolts, such as:

The spaces are just long enough to raise the PCB above a surface, however to mount the boards anywhere useful you would need longer ones. You may also want to remove the IDC sockets if you want to mount the module close to the surface of a panel. This would be a simple desoldering task as they are through-hole sockets:

The board is controlled by a TM1638 IC:

This part seems to be a domestic Chinese product from “Titan Micro Electronics“. After a quick search the TM1638 isn’t available from Digikey, Mouser or the element14 group… so if anyone has a lead on a low-volume, reliable supplier for these – please leave a comment below. However here is a link to the data sheet – thanks Marc!.

Getting Started

Now to make things happen…

Hardware – Connection to an Arduino-compatible board (or other MCU) is quite simple. The pinouts are shown on the rear of the PCB, and match the fitting on the ribbon cable. If you look at the end of the cable as such:

The top-right hole is pin one, with the top-left being pin two, the bottom-right pin nine and bottom-left pin ten. Therefore the pinouts are:

  1. Vcc (5V)
  2. GND
  3. CLK
  4. DIO
  5. STB1
  6. STB2
  7. STB3
  8. STB4
  9. STB5
  10. not connected

For Arduino use, pins 1~4 are the minimum necessary to use one module. Each additional module will require another digital pin connected to STB2, STB3, etc. More on this later. Please note that each module set to full brightness with every LED on consumes 127mA, so it would be wise to use external power with more than one module and other connections with Arduino boards. After spending some time with the module, I made a quick shield with an IDC header to make connection somewhat easier:

Software –  download and install the T1638 library from here. Thanks and kudos to rjbatista at gmail dot com for the library. Initialising modules in the sketch is simple. Include the library with:

then use one of the following for each module:

x is  the Arduino digital pin connected to the module cable pin 4, y is the Arduino digital pin connected to the module cable pin 3, and z is the strobe pin. So if you had one module with data, clock and strobe connected to pins 8, 7,  and 6 you would use:

If you had two modules, with module one’s strobe connected to Arduino digital 6, and module two’s strobe connected to digital 5, you would use:

and so on for more modules.  Now to control the display…

The bi-colour LEDs

Controlling the red/green LEDs is easy. For reference they are numbered zero to seven from left to right. To turn on or off a single LED, use the following:

Using the method above may be simple it is somewhat inefficient. A better way is to address all of the LEDs in one statement. To do this we send two bytes of data in hexadecimal to the display. The MSB (most significant byte) consists of eight bits, each representing one green LED being on (1) or off (0). The LSB (least significant byte) represents the red LEDs.

An easy way to determine the hexadecimal value to control the LEDs is simple, image you have one row of LEDs – the first eight being green and the second eight being red.  Set each digit to 1 for on and 0 for off. The convert the two binary numbers to hexadecimal and use this function:

Where green is the hexadecimal number for the green LEDs and red is the hexadecimal number for the red LEDs. For example, to turn on the first three LEDs as red, and the last three as green, the binary representation will be:

00000111 11100000 which in hexadecimal is E007. So we would use:

which produces the following:

The 7-segment display

To clear the numeric display (but not the LEDs below), simply use:

or to turn on every segment AND all the LEDs, use the following

To display decimal numbers, use the function:

where a is the integer, b is the position for the decimal point (0 for none, 1 for digit 8, 2, for digit 7, 4 for digit 6, 8 for digit 4, etc), and the last parameter (true/false) turns on or off leading zeros. The following sketch demonstrates the use of this function:

and the results:

One of the most interesting features is the ability to scroll text across one or more displays. To do so doesn’t really need an explanation as the included demonstration sketch:

included with the TM1638 library is easily followed. Just insert your text in the const char string[], ensure that the module(s) are wired according to the module definition at the start of the sketch and you’re set. To see the available characters, visit the function page. Note that the display is only seven-segments, so some characters may not look perfect, but in context will give you a good idea – for example:

Finally, you can also individually address each segment of each digit. Consider the contents of this array:

each element represents digits 1~8. The value of each element determines which segment of the digit turns on. For segments a~f, dp the values are 1,2,4,6,16,32,64,128. So the results of using the array above in the following function:

will be:

Naturally you can combine values for each digit to create your own characters, symbols, etcetera. For example, using the following values:

we created:

The buttons

The values of the buttons are returned as a byte value from the function:

As there are eight buttons, each one represents one bit of a binary number that is returned as a byte. The button on the left returns decimal one, and the right returns 128. It can also return simultaneous presses, so pressing buttons one and eight returns 129. Consider the following sketch, which returns the values of the button presses in decimal form, then displays the value:

and the results:

Update – 21/05/2012

A reader from Brazil has used one of the modules as part of a racing simulator – read more about it here, and view his demonstration below.

Update – 08/02/2013

Great tutorial on using these with a Raspberry Pi.

These display boards were a random, successful find. When ordering from dealextreme, do so knowing that your order may take several weeks to arrive as they are not the fastest of online retailers; and your order may be coming from mainland China which can slow things down somewhat. Otherwise the modules work well and considering the minimal I/O and code requirements, are a very good deal.

Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our 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.

Posted in arduino, lesson, part review, raspberry pi, TM1638, tutorial34 Comments

Review: The Gravitech Arduino Nano family

Hello Readers

In this article we will examine a variety of products received for review from Gravitech in the United States – the company that designed and build the Arduino Nano. We have a Nano and some very interesting additional modules to have a look at.

So let’s start out review with the Arduino Nano. What is a Nano? A very, very small version of our Arduino Duemilanove boards. It contains the same microcontroller (ATmega328) but in SMD form; has all the I/O pins (plus two extra analogue inputs); and still has a USB interface via the FT232 chip. But more on that later. Nanos arrive in reusable ESD packaging which is useful for storage when not in use:

Patriotic Americans should note that the Nano line is made in the USA. Furthermore, here is a video clip of Nanos being made:

For those who were unsure about the size of the Nano, consider the following images:

You can easily see all the pin labels and compare them to your Duemilanove or Uno board. There is also a tiny reset button, the usual LEDs, and the in circuit software programmer pins. So you don’t miss out on anything by going to a Nano. When you flip the board over, the rest of the circuitry is revealed, including the FTDI USB>serial converter IC:

Those of you familiar with Arduino systems should immediately recognise the benefit of the Nano – especially for short-run prototype production. The reduction in size really is quite large. In the following image, I have traced the outline of an Arduino Uno and placed the Nano inside for comparison:

So tiny… the board measures 43.1mm (1.7″) by 17.8mm (0.7″). The pins on this example were pre-soldered – and are spaced at standard 2.54mm (0.1″) intervals – perfect for breadboarding or designing into your own PCB –  however you can purchase a Nano without the pins to suit your own mounting purposes. The Nano meets all the specifications of the standard Arduino Duemilanove-style boards, except naturally the physical dimensions.

Power can be supplied to the Nano via the USB cable; feeding 5V directly into the 5V pin, or 7~12 (20 max, not recommended) into the Vin pin. You can only draw 3.3V at up to 50 mA when the Nano is running on USB power, as the 3.3V is sourced from the FTDI USB>serial IC. And the digital I/O pins still allow a current draw up to 40 mA each. From a software perspective you will not have any problems, as the Nano falls under the same board classification as the (for example) Arduino Duemilanove:

Therefore one could take advantage of all the Arduino fun and games – except for the full-size shields. But as you will read soon, Gravitech have got us covered on that front. If the Arduino system is new to you, why not consider following my series of tutorials? They can be found here. In the meanwhile, to put the size into perspective – here is a short video of a Nano blinking some LEDs!

Now back to business. As the Nano does not use standard Arduino shields, the team at Gravitech have got us covered with a range of equivalent shields to enable all sorts of activities. The first of this is their Ethernet and microSD card add-on module:

and the underside:

Again this is designed for breadboarding, or you could most likely remove the pins if necessary. The microSD socket is connected as expected via the SPI bus, and is fully compatible with the default Arduino SD library. As shown in the following image the Nano can slot directly into the ethernet add-in module:

The Ethernet board requires an external power supply, from 7 to 12 volts DC. The controller chip is the usual Wiznet 5100 model, and therefore the Ethernet board is fully compatible with the default Ethernet Arduino library. We tested it with the example web server sketch provided with the Arduino IDE and it all just worked.

The next add-on module to examine is the 2MOTOR board:

… and the bottom:

Using this module allows control of two DC motors with up to two amps of current each via pulse-width modulation. Furthermore, there is a current feedback circuit for each motor so you measure the motor load and adjust power output – interesting. So a motorised device could sense when it was working too hard and ease back a little (like me on a Saturday). All this is made possible by the use of the common L298 dual full-bridge motor driver IC. This is quite a common motor driver IC and is easy to implement in your sketches. The use of this module and the Nano will help reduce the size of any robotics or motorised project. Stay tuned for use of this board in future articles.

Next in this veritable cornucopia of  add-on modules is the USBHOST board:

turning it over …

Using the Maxim MAX3421E host controller IC you can interface with all sorts of devices via USB, as well as work with the new Android ADK. The module will require an external power supply of between 7 and 12 volts DC, with enough current to deal with the board, a Nano and the USB device under control – one amp should be more than sufficient. I will be honest and note that USB and Arduino is completely new to me, however it is somewhat fascinating and I intend to write more about using this module in the near future. In the meanwhile, many examples can be found here.

For a change of scene there is also a group of Xbee wireless communication modules, starting with the Xbee add-on module:

The Xbee itself is not included, only shown for a size comparison. Turning the module over:

It is nice to see a clearly-labelled silk screen on the PCB. If you are unfamiliar with using the Xbee wireless modules for data communication, you may find my introductory tutorial of interest. Furthermore, all of the Gravitech Nano modules are fully software compatible with my tutorial examples, so getting started will be a breeze. Naturally Gravitech also produce an Xbee USB interface board, to enable PC communication over your wireless modules:

Again, note that the Xbee itself is not included, however they can be supplied by Gravitech. Turning the board over reveals another highly-detailed silk screen:

All of the Gravitech Xbee modules support both series 1.0 and 2.5 Xbees, in both standard and professional variants. The USB module also supports the X-CTU configuration software from Digi.

Finally – leaving possibly the most interesting part until last, we have the MP3 Player add-on board:

and on the B-side:

The MP3 board is designed around the VS1053B MP3 decoder IC. It can also decode Ogg Vorbis, AAC, WMA and MID files. There is a 3.5mm stereo output socket to connect headphones and so on. As expected, the microSD card runs from the SPI pins, however SS is pin 4. Although it may be tempting to use this to make a home-brew MP3 player, other uses could include: recorded voice messages for PA systems such as fire alarm notices, adding sound effects to various projects or amusement machines, or whatever else you can come up with.

Update – We have examined the MP3 board in more detail with a beginner’s tutorial.

The Arduino Nano and related boards really are tiny, fully compatible with their larger brethren, and will prove very useful. Although this article was an introductory review, stay tuned for further projects and articles that will make use of the Nano and other boards. If you have any questions or enquiries please direct them to Gravitech via their contact page. Gravitech products including the Arduino Nano family are available directly from their website or these distributors.

As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts, follow on twitterfacebook, or join our Google Group.

[Disclaimer – the products reviewed in this article are promotional considerations made available by Gravitech]

High resolution photos are available on flickr.

Otherwise, have fun, be good to each other – and make something! 

Posted in arduino, ethernet, gravitech, microcontrollers, mp3, nano, part review, xbee0 Comments

The world’s smallest oscilloscope??

Hello readers

Today we examine a tiny and fascinating piece of test equipment from Gabotronics – their XMEGA Xprotolab. Sure, that sounds like a lot – and it is. Yet the functionality of the Xprotolab is inversely proportional to its physical size. Try to imagine having an oscilloscope, arbitrary waveform generator, logic analyser and a spectrum analyser – including a display – in a package no larger than 25.4 x 40.6 mm (1″ x 1.6″) in size. Well imagine no more as here it is:


As described above, this tiny marvel of engineering has the following functions:

  • Two analogue oscilloscope channels with a maximum sampling rate of 2 million samples per second;
  • Analogue bandwidth of 320 kHz at 8-bits resolution;
  • Buffer size of 256 samples;
  • Fast fourier-transform;
  • Analog and external digital triggering;
  • Maximum input voltage of +/- 10V;
  • Automatic average and peak-to-peak measurements;
  • Logic analyser with eight channel maximum simultaneous monitoring;
  • Firmware is user upgradable;
  • Can also be used as a development board for the XMEGA microcontroller (extra items required);
  • When powered from a USB cable, the board can supply +/-5V and +3.3V into a solderless breadboard.

The OLED screen is very clear and precise, which considering the size of 0.96″ – very easy to read. One can also set the display mode to invert which changes the display to black on white, bringing back memories of the original Apple Macintosh:


Using the Xprotolab took a little getting used to, however after pressing menu buttons for a few minutes I had it worked out. The more sensible among you will no doubt read the instructions and menu map listed at the website. Having the dual voltmeter function is quite useful, it saved me having to mess about with a couple of multimeters when trying to debug some analogue circuits I’m currently working with.

The display can be as complex or as simple as you choose, for example when working with the oscilloscope you can disable one channel and shift the waveform so it occupies the centre of the screen. Or when working with the logic analyser, you can choose to only select the channels being monitored, instead of filling the screen with unused logic lines.

There are a couple of things to take care with. When inserting the Xprotolab into your breadboard, be careful not to put pressure on the OLED display when pushing down; when removing it from the breadboard, try and do so evenly with the help of an DIP IC puller.

Generally in my reviews there is a video clip of something happening. Unfortunately my camera just isn’t that good, so below is the demonstration clip from the manufacturer:

As you can see the Xprotolab would be quite useful for monitoring various signals whilst prototyping, as you can just drop it into a breadboard. Furthermore, if your required range is measurable the Xprotolab saves you having to look back-and-forth between a prototype and the display from a regular oscilloscope as well.

As the purchase price is relatively cheap compared against the time and effort of trying to make an OLED display board yourself, one could also plan to build an Xprotolab into a final design – considering a lot of measurement and display work is already done for you it could be a real time-saver. The Xprotolab can run from a 5V supply and only draws a maximum of 60 milliamps. Product support is quite extensive, including source code, schematics, videos, a user forum and more available from the product page.

In conclusion the Xprotolab is genuinely useful, inexpensive and ready to use out of the box. It would make a useful piece of test equipment for a beginner or seasoned professional, and also integrates well into custom projects when required.

Remember, if you have any questions about the Xprotolab,  please contact Gabotronics via their website.

[Note – the Xprotolab reviewed in this article was received from Gabotronics for review purposes]

Posted in gabotronics, oscilloscope, part review, review, xmega, xprotolab8 Comments

Review – CD4047 Astable/Monostable Multivibrator

Hello readers!

Today we are going to examine an older but still highly useful integrated circuit – the 4047 Astable/Monostable multivibrator:


My reason for doing this is to demonstrate another way to create a square-wave output for digital circuits (astable mode) and also generate single pulses (monostable mode). Sometimes one can get carried away with using a microcontroller by default – and forget that there often can be simpler and much cheaper ways of doing things. And finally, the two can often work together to solve a problem.

What is a multivibrator? In electronics terms this means more than one vibrator. It creates an electrical signal that changes state on a regular basis (astable) or on demand (monostable). You may recall creating monostable and astable timers using the 555 timer described in an earlier article. One of the benefits of the 4047 is being able to do so as well, but with fewer external components. Here is the pinout diagram for a 4047 (from the Fairchild data sheet):

Note that there are three outputs, Q, Q and OSC out. Q is the normal output, Q is the inverse of Q – that is if Q is high, Q is low – at the same frequency. OSC output provides a signal that is very close to twice the frequency of Q. We will consider the other pins as we go along. In the following small video, we have LEDs connected to all three outputs – you can see how Q and Q alternate, and the increased frequency of OSC out:

That was an example of the astable mode.  The circuit used is shown below. The only drawback of using a 4047 is that you cannot alter the duty cycle of your astable output – it will always be 50% high and 50% low. The oscillator output is not guaranteed to have a 50% duty cycle, but comes close. The time period (and therefore the frequency) is determined by two components – R1 and the capacitor:

[Quick update – in the schematic below, also connect 4047 pin 14 to +5V]


The values for R2~R4 are 560 ohms, for the LEDs. R1 and the capacitor form an RC circuit, which controls the oscillation frequency. How can we calculate the frequency? The data sheet tells us that time (period of time the oscillator is ‘high’) is equal to 4.4 multiplied by the value of R1 and the capacitor. As the duty cycle is always 50%, we double this value, then divide the result into one. In other words:

And as the frequency from the OSC out pin is twice that of Q or Q, the formula for the OSC out frequency is:

However the most useful formula would allow you to work with the values of R and C to use for a desired frequency f:

When calculating your values, remember that you need to work with whole units, such as Farads and Ohms- not microfarads, mega-ohms, etc. This chart of SI prefixes may be useful for conversions.

The only thing to take note of is the tolerance of your resistor and capacitor. If you require a certain, exact frequency try to use some low-tolerance capacitors, or replace the resistor with a trimpot of a value just over your required resistor value. Then you can make adjustments and measure the result with a frequency counter. For example, when using a value of 0.1uF for C and 15 k ohm for R, the theoretical frequency is 151.51 Hz; however in practice this resulted with a frequency of 144.78 Hz.

Don’t forget that the duty cycle is not guaranteed to be 50% from the OSC out pin. This is shown in the following demonstration video. We measure the frequency from all three output pins, then measure the duty cycle from the same pins:

(The auto-ranging on that multimeter is somewhat annoying).

Now for some more more explanation about the 4047. You can activate the oscillations in two ways, via a high signal into pin 5 (pin 4 must then be low) or via a low signal into pin 4 (and pin 5 must be low). Setting pin 9 high will reset the oscillator, so Q is low and Q is high.

The monostable mode is also simple to create and activate. I have not made a video clip of monstable operation, as this would only comprise of staring at an LED. However, here is an example circuit with two buttons added, one to trigger the pulse (or start it), and another to reset the timer (cancel any pulse and start again):

[Quick update – in the schematic below, also connect 4047 pin 14 to +5V]


The following formula is used to calculate the duration of the pulse time:

Where time is in seconds, R is Ohms, and C is Farads. Once again, the OSC output pin also has a modified output – it’s time period will be 1.2RC.

To conclude, the 4047 offers a simple and cheap way to generate a 50% duty cycle  square wave or use as a monostable timer. The cost is low and the part is easy to source. As always, avoid the risk of counterfeit ICs and get yours from a reputable distributor. Living in Australia, mine came from element-14. Thanks to Fairchild Semiconductor for product information from their 4047 data sheet.

Have fun and keep checking into Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our 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.

Posted in 4047, education, learning electronics, lesson, part review, tutorial41 Comments

Part review – Linear Technology LTC6991 “Timerblox” low frequency oscillator

Hello Readers

Time for a new component review – the Linear Technology LTC6991 low frequency oscillator. This is part of Linear‘s Timerblox series of tiny timing devices. The full range is described on their web site. It is available in DFN or SOT-23 (below)  packaging. Our example for today:

The graph paper in the image is 5mm square, so the IC itself is tiny yet worthwhile challenge. Although reading the data sheet may convince you it is a difficult part to use, it is actually quite simple. This article will give you the “simple way”. Once again I have lashed out and will hand-solder an SMD onto a SOT-23 board:

Messy, but it works. Moving along…

My reason for examining the LTC6991 was as a lower-power substitute to using a 555 timer to create a square wave at various frequencies. Normally I wouldn’t give two hoots about the current draw, as everything on my bench is powered from a lab supply.

However when designing things for external use, they are usually powered by a battery of some sort or solar – so the less current drawn the better. The bog-standard TI NE555 has a current draw (with output high) of between two and five milliamps (at 5V). Which doesn’t sound like much – but our 6991 is around 100 to 170 microamps at 5V. These figures are for the respective timers without an output load. You can source up to 20mA from the output of the 6991, and when doing so will naturally increase the current load – but still it will be less than our triple-nickel.

The LTC6991 offers a period range of 1 millisecond to 9.5 hours; which translates to a frequency range of 29.1 microhertz to 977 Hz, with a maximum frequency error or <1.5%. Only one to three external resistors are required to setup your timing requirements. For a more detailed explanation, please see the data sheet.pdf. The duty cycle defaults to 50% however this can be altered by using the IC in voltage-controlled period mode.

Linear have made using the IC very easy by providing an Excel spreadsheet you can use to make your required calculations, available from this page. For example, to create a 1 Hz oscillator, we enter our figures in as such:

and the macro returns the following details:


Very convenient – a schematic, the required resistors, and example timing diagram. I recreated this example, however not having the exact values in stock caused a slight increase in frequency – with Rset at 750k,  Rdiv1 at 910k and Rdiv2 at 180k my frequency was 3.1 Hz. Therefore to match the accuracy of the LTC6991 you need to ensure a your external components are close to spec and a very low tolerance. It produces a good square-wave:


If you cannot use the exact resistor values recommended, use resistors in series or parallel to achieve the desired values. Don’t forget to measure them in real life if possible to ensure your accuracy does not suffer.

Pin one (RST) can be left floating for nomal oscillation, when high it resets the IC and forces output (pin six) low. As you can see, it is very simple to use especially with the provided spreadsheet. The required formulae are also provided in the data sheet if you wish to do your own calculations. Pulse width can be controlled with a fourth resistor Rpw, and is explained on page sixteen of the data sheet.

Although physically it may be difficult to use as it is SMD, the power requirements and the ability to generate such a wide range of oscillations with so few external parts makes the LTC6991 an attractive proposition.

The LTC6991 and the Timerblox series are new to market and should be available from the usual suppliers in the very near future such as RS and element-14.

As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts. Or join our Google Group.

[Note – The LTC6991was a personally-ordered sample unit from Linear and reviewed without notification]

Posted in education, LTC6991, part review, tutorial4 Comments

Review – Starman Electric Databridge Wireless I/O Modules

In this review we are going to have a look at some new wireless data modules that have just arrived on the market. They are the Databridge Wireless I/O modules from Starman Electric. Although there are many types of wireless modules out there, such as the discount 315 MHz units that are somewhat unreliable (well for me); and the great XBee series (as we used in Moving Forward with Arduino – Chapter Fourteen) – these Starman modules take it to the next level. How?

The concept of a databridge is a delightfully simple one. The two modules take the place of a wire. Digital, analogue, UART, even PC serial. No firmware settings to adjust, just plug them in and they work!

First of all, there are two physical types of unit, either DIP mount or SMD. The units below are the DIP version, 1mW output power:


The graph paper is 5mm square, and the module measures 53.85mm by 25.91mm. The DIP packaging (above) is meant for experimenters and prototypes, you can order SMD versions for production runs. There are also two power-output versions, 1mW with a theoretical range of 1km, and a 100 mW with a range of 4km. The higher power modules require the use of an external antenna. They require 3.3 volts DC, with a peak current draw of 37mA for the 1mW, and 120mA for the 100mW. For demonstration purposes I am using a Texas Instruments LP2950 to provide 3.3 volts DC at up to 100 mA.

Although the specification sheet is quite long (and you can download it from here) there are a few features that really stand out, including:

  • Automatic connection – a pair of modules will ‘lock’ onto each other without any extra work by the user;
  • A very high sampling rate of 200 samples per second with a latency of five millisconds;
  • Spread-spectrum radio operation – the modules will skip frequencies themselves for reliable connections;
  • You can have sixteen unique pairs working in the same area without cross-interference;
  • You can have two analogue channels and multiple digital channels simultaneously.

But enough talking, time to put them to the test. I will recreate some examples found in the Getting Started manual available for download here.

As I only have one pair of modules, and somehow I think my neighbours won’t be using any at this point in time, there is no need to set the pair’s unique network ID. However you do need to specify the master and slave in the module relationship (no switches…), which is done with pin 4 – to Vcc for master, and pin 4 to GND for slave. Now on with the show!

The first example of interest is number two in the guide – the wireless digital and analogue I/O bridge. To me this seems like an interesting wireless “repeater” to some Arduino analogue and digital outputs. Here is my test schematic used for the demonstrations in this review:


and my usual messy breadboards:

Well this is a temporary test! The slave module board is running from a 9V PP3 battery so I can take it for a walk.

Anyhow, the setup is – four digital out lines from an Arduino, which are either high or low (+5v or GND). These are connected to pins ‘digital signal’ 1~4 on the master Databridge. Furthermore, Arduino analogue pin 1 went to the Databridge ‘analog signal’ pin 1. At the slave side of things, there are four LEDs with current limiting resistors connected to pins ‘digital signal’ 1~4; and two wires each from ‘analog signal’ 1 would be connected to a voltmeter. The digital output pins on slave modules default to ‘high’ unless driven otherwise.

Finally, there is also an LED and current limiting resistor coming from pin 32 of each unit – the ‘link’ pin. The link pin is a lifesaver. Here is a great feature – when the pair of units are within range of each other and matched as a pair, link goes high (3.3V). Out of range? It goes low (0V). Therefore you can test the range on these modules just by powering them up on a breadboard each, with the LEDs on pin 32, and go for a walk with a unit. When the LED is off – you’re out of range. And when you come back into range, the modules reconnect automatically.

Back to the test. First I just created a loop which turned the digital pins on and off, and the matching LEDs on the slave unit blinked on and off as expected. No extra code, no trying to create wacky functions to multiplex/demultiplex signals – this just works. The modules are like an invisible bunch of wires between two points. Never has anything wireless worked so easily for me.

Here is a quick video clip, first notice the lonely LEDs on each breadboard – the are the link LEDs. When I power cycle the master or slave, notice how quickly they reconnect. Please note that the slave unit retains the state of the digital outputs if connection is lost. So if a pin is high while connected – if the module loses radio contact, the pin will stay high.

The theoretical maximum working range is quoted as 1km for these 1mW modules. My indoor test allowed a distance of 11 metres, with three concrete walls of a thickness of ~110mm in between. Unfortunately living in my area I could not find a flat, open area large enough to test the maximum open-air range – however considering the indoor ‘concrete wall’ test and my experience with other wireless equipment of this power output, it would be accurate in an outdoor, line-of-sight application. As always, conduct your own real-life tests before making any project commitments  and so on.

And as always, I was curious about the current draw of the units while in use. The master module with the link LED on measured 53 milliamps, with the slave at the boundary of the radio range:


The current use only dropped around 2 or 3 milliamps when the slave was next to the master. The slave module used 59 milliamps with the link LED on:


Therefore taking the LED current draw into consideration, the power usage of these modules is quite low considering the level of communication between them and the high sampling rate.

The next test was to see how the analogue data lines performed. According to example four in the Getting Started guide, the modules will reproduce an input of between 0 and 2.4 volts DC. So I have placed an 11k ohm resistor in series with a 10k ohm potentiometer with analog input 1, and measured the resulting output from the slave. Notice how I still have the digital data lines in use while using the analogue line.  Here is a short clip of this in action:

Amazing – a multitasking wireless module. Note that you could always use an op-amp to boost the output voltage back to the 0~5V DC range, an example of this is on page nine of the Getting Started guide.

Those above were but two from the many possibilities available when using these units:

  • wireless serial data links
  • remote on/off control of six items
  • robotics remote control
  • microcontroller I/O wireless extension…

Frankly – if you need to wirelessly connect more than one data line simultaneously, you have an excellent solution with the Databridge modules.

Update! – Radio licensing information:

These modules operate in the 2.4 GHz ISM (industrial, scientific and medical) band. For those in the USA, the Databridge is an FCC-approved “class B” device, and is only for use by OEM integrators (see page 16 of the datasheet.pdf). Starman Electric also state that the Databridge is certified for Canada and the EU (ETSI).

For those here in Australia, these units are operated under the conditions of the Radiocommunications (Low Interference Potential Devices) Class Licence 2000, and I feel are classed as “spread spectrum unit” under the preceding license.

Please conduct your own research with regards to radio transmitter licensing in your area. Furthermore, please read the tronixstuff “boring stuff” here.

But enough about that, where you can get them?

Australian customers can purchase these modules from our local distributor – Interworld Electronics; North Americans and the rest of the world directly via Starman Electric.

Remember, if you have any questions about these modules please contact Starman Electric via their website.

[Note – these wireless modules were loan units received from Starman Electric for review purposes]

Posted in databridge, part review, starman, wireless7 Comments

Kit Review – adafruit industries XBee adaptor kit

Hello readers

Today we are going to examine a small yet useful kit from adafruit industries – their XBee adaptor kit. The purpose of doing so was to save some money. How? I needed another XBee USB explorer board to connect a PC to an XBee (as we have done in Moving Forward with Arduino – Chapter Fourteen), but they are around Au$33. However I already have an FTDI USB cable, so all I really need is this kit, as it will work with the FTDI cable. So this saves me around $20.

As usual the adafruit kit packaging is simple, safe and reusable:


The components included are good as usual, including a great solder-masked, silk-screened PCB and an excess of header pins. Got to love a bonus, no matter how small:


This did not take very long to assemble at all. After checking the parts against the parts list, it was time to fire up the iron and solder away. As usual the kit is almost over-documented on the adafruit web pages. But that is a good thing…


Be careful when you place R3, make sure it doesn’t lean in towards the end of the IC too much, otherwise they could touch, or even worse – stop the IC from being seated properly:


Regular readers will know I get annoyed when IC sockets are not included with kits – but for the first time it is fine with me. If you use a socket, the IC will be elevated too much and stop the XBee from being inserted onto the board. But apart from R3 almost stopping the show, everything went smoothly. At the time you need to solder in the 2mm header socket strips for the XBee, the easiest way (if possible) is to seat an XBee in the sockets, then into the PCB:


Once you have followed the excellent instructions, the last thing to solder is the pins for the FTDI cable. You can either lay them out flat on the PCB, or insert them through the holes. This is my preferred way, and seating the lot in a breadboard to hold it steady is a good idea:


And finally, we’re finished:


A quick check with Windows to ensure everything is OK:

And we are ready for communications. This was a very simple and inexpensive board to assemble – and excellent value if you need USB connection to your PC and you already have an FTDI cable.

Well I hope you found this review interesting, and helped you think of something new to make with XBees. You can purchase the kit directly from adafruit industries.

As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts. Or join our new Google Group. High resolution images are available on flickr.

[Note – The kit was purchased by myself personally and reviewed without notifying the manufacturer or retailer]

Posted in adafruit, kit review, part review, WRL-08687, xbee2 Comments

Review – Macetech Shiftbrite RGB LED module

Hello readers

Today we are going to examine the Macetech Shiftbrite modules. These are high-powered RGB LEDs that are mounted on a small PCB with a controller IC that you can control easily with an AVR or Arduino system, with a brightness of 8800 mcd per colour, and a viewing angle of 140 degrees. Ouch! In this review we will be using the Arduino system, however there is AVR instructions and a demonstration available here. First of all, here is one example:



The IC on the bottom of the unit is an Allegro A6281 three-channel constant current LED driver with programmable pulse-width modulation control. For interest, here is the data sheet: Allegro 6281.pdf In other words, it takes care of which LED segment(s)to illuminate, their brightness, and for how long. It sounds like a lot but is easy to  understand.

The name Shiftbrite is a bit of a giveaway to how it actually works. It is very bright – looking at it directly during operation is dangerous, and the shift relates to how the control data is used by the modules.  To put it simply they are 32-bit shift registers with an RGB LED attached… so all you need to do is have 32 bits of data sent to them – in a similar method just like a 74HC595 shift register. The good thing about this is you can control more than one Shiftbrite using a daisy-chain method – with a catch. If you have, say, three in a row and you only want to change the second Shiftbrite, you need to send out data to refresh all three of them. But don’t panic, doing so is quite easy.

There are two concepts to understand to effectively use a Shiftbrite – pulse width modulation and how colours are represented digitally. PWM is quite easy with LEDs, it is a method of controlling the brightness by switching them on and off rapidly to give the illusion of brightness. For example, at full PWM, the LED is on… at 50 % the LED is on for 50% of the time, and off for 50% of the time. Below is a demonstration of PWM from another article:

Representing colours digitally is also easy. As you may know, colours can be created by mixing the primary colours red, green and blue. With the Shiftbrite each primary colour can have a value of between zero (off) and 1023 (full). Say for example, you only want red – so you set the data to be: red – 1023, green – zero, blue zero. And so on. For a very good explanation on how this works please visit this site. The Shiftbrite uses 10 bits of data for each colour, allowing a range of resulting colours in the billions. So let’s get blinking…

Here is an example sketch from the Macetech website:

Connection to the board is very easy, just 5V and GND, and the four data lines:


The only concern when running Shiftbrites is their power consumption. One unit will use 20 mA per primary colour, which is fine for an Arduino or compatible board. However if you are using two or more, you will need to supply an external power supply to the Shiftbrites, between 5.5 and 9 volts, and 60 mA per module. Moving on, here is a video of one Shiftbrite in action, just rotating between red, green and blue:

That is bright. The only thing better than one Shiftbrite is two, so here you are. In the second demonstration, we are using the same sketch as in the first. So the second Shiftbrite is reacting to the data as shifted out by the first when it receives new data:

So now for some more colours. Using the following sketch demo 2.pdf the Shiftbrite generates shades of primary colours, then all the colours randomly. This time to save my eyesight it uses the ping-pong ball diffuser from the blinky project:

Well I hope you found this review interesting, and helped you think of something new to make. In conclusion I would consider the Shiftbrite great for use in projects where you need the blinking and display fun of RGB LEDs, but with a greater brightness.

As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts. Or join our new Google Group.

[Note – The Shiftbrites were purchased by myself personally and reviewed without notifying the manufacturer or retailer]

Posted in arduino, COM-10075, macetech, microcontrollers, part review, shiftbrite, tutorial2 Comments

Review – Texas Instruments TLC5940 16-channel LED driver IC

Hello readers

Today we are going to examine the Texas Instruments TLC5940 16-channel LED driver IC. My reason for doing this is to demonstrate another, easier way of driving many LEDs as well as LED display modules that are common-anode. If you have a common-cathode display module, you should have a look at the Maxim MAX7219. Moving along, here is the IC:


Another nice big DIP IC. Also available in HTSSOP and QFN packaging. What can this IC do for us? It can control 16 LEDs per IC, and also be cascaded to control more and more, with the display data arriving via a serial line in the same manner as a 74HC595 shift register. Furthermore, another benefit of this IC is that you don’t need matching current-limiting resistors for your LEDs, as this IC is a current sink, in that the current flows from the 5V rail, through the LED, then into the IC. However, it can control the brightness of the LEDs using pulse-width modulation over 4096 steps via software, or using a single resistor.

What is pulse-width modulation? Normally an LED might be on, or off. But if you switch it on and off very quickly, it does not look as bright (as it is not on 100% of the time). If you alter the period of time between on and off, you can alter the perceived brightness of the LED. Here is an example, compare the brightness of the LED bars against the display of the CRO – as the brightness increases, the voltage (amplitude [vertical thickness]) spreads across the entire time period (horizontal axis); as the brightness decreases, the voltage spread across time retreats:

Using the IC is very easy on the hardware front. Here is the data sheet: TLC5940.pdf. The pinout diagram is quite self-explanatory:

Pins OUT0~OUT15 are the current-sink pins for each LED. When one is selected they allow current to flow into the IC from the 5V rail, with the LED in between – turning it on. However it is easier to understand with a practical example, such as this:


If you are using an Arduino Mega-style board, the wiring is a little different, please see here for the instructions.

Here we have our Arduino board or compatible sending serial data to the TLC5940 to control sixteen LEDs. The 2k ohm resistor is required to set the maximum current available to flow through the LEDs, thereby adjusting their brightness. Using software you can adjust the brightness with PWM for each LED by itself. Very important: this circuit will need external power into the Arduino or a separate 5V power supply. The circuitry on the breadboard draws up to ~318 mA by itself – running the Arduino from USB only made it somewhat flaky in operation. Here is the circuit in action with an ammeter between the breadboard and 5V out on the Arduino:

Anyhow, let’s get moving once more – here is the assembled demonstration circuit:


For our example, we will be using the Arduino way of doing things. Thankfully (once more) there is a library to make controlling the IC exponentially easier. The library page and download files are available from here.  If you need guidance on installing a library, please visit here. However the commands to control the IC are quite simple with the Arduino library.

First of all, include the TLC5940 library, as such:

Then in void setup(); you create the object using the function:

You can insert a number between 0 and 4095 to set the starting PWM (LED brightness) value, however this is optional. Setting an output for display requires two functions, first Tlc.set(l, p); where l is the output (0~15) and p is the PWM brightness level – then execute Tlc.update(); which sends the command to the IC to be executed. The sketch below is easy to follow and understand the process involved.

Moving forward with the demonstration, here is the sketch  – TLC5940demo.pdf, and the video clip of operation:

When the LEDs are glowing from dim to bright and return, we are altering the PWM value of the LEDs to adjust their brightness. This also occurs during the last operation where the LEDs are operating like the bonnet of KITT.

Below is an example of TLC5940 use by JM – he has made an awesome RGB LED cube:

Well once again that’s enough blinkiness for now, again this is another useful IC that helps simplify things and be creative. As always, avoid the risk of counterfeit ICs  – so please avoid disappointment, support your local teams and buy from a reputable distributor. Living in Australia, mine came from element-14 (part number 1226306). So have fun! High resolution photos are available from flickr.

Remember, if you have any questions at all please leave a comment (below). We also have a Google Group dedicated to the projects and related items on the website – please sign up, it’s free and we can all learn something.

Posted in arduino, lesson, part review, tlc5940, tutorial28 Comments

Part review – NXP 74HC238 Decoder/demultiplexer

Hello readers

Today we are going to examine the 74HC238 decoder/demultiplexer IC. My reason for writing this was to examine another way to get more output pins when using an Arduino or compatible board. However you can use any combination of three logic lines to turn on or off eight mutually exclusive outputs. How? Let’s find out…

First of all, here is the IC:


It is also available in SO16, SSOP16,  TSSOP16 and DHVQFN16 packages. What? Here is a good list of various SMD packaging types. The pin layout is very simple, apart from +5V and ground, you have six pins that control the outputs, and eight output pins, however in reality you only need to control three from the microcontroller or other logic lines. Here is the pinout diagram:

To get the output pins high, you use a combination of levels on 74HC238 pins A0~A2 and possibly E3. If you leave E3 low, no outputs can be set to high. The input combination required for each output is described in this table from the data sheet:


Notice that columns with an X can be set either high or low, but you must not leave them floating, so always connect or set an X to high or low. If you need to have active low outputs (that is, outputs are high instead of low), there is the 74HC138. So now to do this in real life! Here is a demonstration schematic to use the 74HC238 with an Arduino Uno or 100% compatible board:


… and in real life:


And here is a demonstration video, using the following sketch: