Welcome to t r o n i x s t u f f
Welcome to the tronixstuff website. Regular articles are published about many things, including analogue and digital electronics, electronic kits, part reviews – and you can also follow our popular series of Arduino tutorials. The latest posts are below, and at your top-right are indexes to previous articles. On the right are ways to subscribe for new post notifications, as well as links to our Google Group for discussion. Look around, learn something. And remember – there is so much more than just Arduino! (“Arduino” is a trademark of Arduino Team).
Before following any tutorials, please read and understand the boring stuff. You follow anything here at your own risk.
The MAX7219 LED display controller – real or fake?
Introduction
If you’re experimenting with various Arduino or other projects and working with LED matrices or lots of LEDs – you may have come across the Maxim MAX7219 “Serially Interfaced, 8-Digit, LED Display Driver” IC. It’s a great part that can drive an 8 x 8 LED matrix or eight digits of seven-segment LED displays very easily. However over the last few years the price has shot up considerably. Supply and demand doing their thing – and for a while there was also the Austria Microsystems AS1107 drop-in replacement, which could be had for a few dollars less. But no more.
So where does the budget-minded person go from here? Charlieplexing? Lots of shift registers? Or dig a little deeper to find some cheaper units. With a MAX7219 heading north of US$10 in single units, they may turn to ebay or other grey-market suppliers in the Far East. Everyone likes to save money – and who can blame them? However with the proliferation of counterfeiting, “third shift” operations and other shifty practices – is buying those cheaper examples worth it?
A few people have been asking me of late, and there’s only one way to find out … so over the last month I ordered eight random “MAX7219s” from different suppliers on ebay and will compare them to the real thing using somewhat unscientific methods, then see how they work. The funny thing was that after five weeks only six of the eight arrived – so there’s risk number one: if it doesn’t come from a reputable supplier, it might not come at all. Funny stuff. Anyhow, let’s get started by looking at the differences between the real MAX7219 and the others.
Pricing differences
The easiest hint is the price. The non-originals are always cheaper. And if you wonder how much the real ones are in bulk, the quickest indicator is to check the Maxim website and that of a few larger distributors For example the Maxim “sticker price” for 1000 units is US$4.18 each:
How much at Digikey? Lots of 500 for US$4.67 each:
And you wouldn’t buy just one from element14 at this price:
However in fairness to element14 they will price match if you’re buying in volume. So if you can get a “MAX7219″ delivered for US$1.50 – there’s something wrong. Moving on, let’s examine some of those cheap ones in more detail.
Visual differences
If you’ve never seen a real MAX7219 – here it is, top and bottom:
And here’s our rogue’s gallery of test subjects:
In a few seconds the differences should be blindingly obvious – look at the positioning of the printed bar across the part, the printing of the logo, and the general quality and positioning of the printing. Next, those circles embedded in the top of the body at both ends of the part, and the semi-circle at the top end. And if you turn them over, there’s nothing on the bottom. Furthermore, there isn’t a divot indicating pin 1 on the fakes, as shown on the real part:
Oh – did you notice the legs on the real one? Look closely again at the image above, then consider the legs on the others below:
Finally, the non-originals are shorter. The Maxim width can fall between 28.96 and 32.13 mm – with our original test MAX7219 being 32 mm:
and all the test subjects are narrower, around 29.7 mm:
Fascinating. Finally, I found the quality of the metal used for the legs to be worse than the original, they were easier to bend and had trouble going into an IC socket. You can find all the physical dimensions and other notes in the data sheet available from the Maxim website. Finally, this packaging made me laugh – knock-offs in knock-off tubes? (Maxim purchased Dallas Semiconductor a while ago)
Weight difference
Considering that they’re shorter, they must weigh less. In the following video I put the original on the scales, tare it to zero then place each test subject – you can see the difference in weigh. The scales are out a bit however the differences are still obvious:
However over time the manufacturers may go to the effort of making copies that match the weight, size and printing – so future copies may be much better. However you can still fall back to the price to determine a copy.
Do they actually work?
After all that researching and measuring – did they work? One of the subjects came with a small LED matrix breakout board kit:
… so I used that with a simple Arduino sketch that turned on each matrix LED one at a time, then went through the PWM levels – then left them all on at maximum brightness.
#include "LedControl.h" LedControl lc=LedControl(12,11,10,1); // data, clock, load, 1 MAX7219
void setup()
{
lc.shutdown(0,false);
lc.setIntensity(0,15);
lc.clearDisplay(0);
}
void single() {
for(int row=0;row<8;row++) {
for(int col=0;col<8;col++) {
delay(25);
lc.setLed(0,row,col,true);
delay(25);
for(int i=0;i
void loop()
{
single();
for (int n=0; n<5; n++)
{
for (int z=0; z<16; z++)
{
lc.setIntensity(0,z);
delay(100);
}
for (int z=15; z>-1; --z)
{
lc.setIntensity(0,z);
delay(100);
}
}
lc.setIntensity(0,15);
do { } while(1);
}
Here’s the real MAX7219 running through the test:
And test subjects one through to six running it as well:
And from a reader request, some current measurements. First the current used by the entire matrix module at full PWM brightness, then with LEDs off, then the MAX7219 in shutdown mode:
Well that was disheartening. I was hoping and preparing for some blue smoke, dodgy displays or other faults. However the little buggers all worked, didn’t overheat or play up at all.
Conclusion
Six random samples from ebay – and they all worked. However your experience may vary wildly. Does this tell us that copies are OK to use? From my own personal opinion – you do what you have to do with respect to your own work and that for others. In other words – if you’re making something for someone, whether it be a gift or a commercial product, or something you will rely on – use the real thing. You can’t risk a fault in those situations. If you’re just experimenting, not in a hurry, or just don’t have the money – try the cheap option. But be prepared for the worst – and know you’re supporting an industry that ethically shouldn’t exist. And at the end – to be sure you’re getting a real one – choose from a Maxim authorised source.
I’m sure everyone will have an opinion on this, so let us know about it in the moderated comments section below. 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 tronixstuff.com. Why not follow things on twitter, Google+, 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.
Tutorial – Arduino and MC14489 LED Display Driver
Learn how to use MC14489 LED display driver ICs with Arduino in chapter fifty-one 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.
Updated 12/05/2013
Introduction
Recently we’ve been looking at alternatives to the MAX7219 LED display driver IC due to pricing and availability issues (stay tuned for that one) – and came across an old but still quite useful IC – the MC14489 from Motorola (now Freescale Semiconductor). The MC14489 can drive five seven-segment LED numbers with decimal point, or a combination of numbers and separate LEDs. You can also daisy-chain more than one to drive more digits, and it’s controlled with a simple serial data-clock method in the same way as a 74HC595 shift register. Sourcing the MC14489 isn’t too difficult – it’s available from element14, Newark, Digikey, and so on – or if you’re not in a hurry, try the usual suspects like Futurlec.
For the purpose of the tutorial we’ll show you how to send commands easily from your Arduino or compatible board to control a five-digit 7-segment LED display module - and the instructions are quite simple so they should translate easily to other platforms. Once you have mastered the single module, using more than one MC14489 will be just as easy. So let’s get started.
Hardware
Before moving forward, download the data sheet (pdf). You will need to refer to this as you build the circuit(s). And here’s our subject in real life:
For our demonstration display we’ll be using a vintage HP 5082-7415 LED display module. However you can use almost any 7-segment modules as long as they’re common-cathode - for example, Sparkfun part number COM-11405. If you’re using a four-digit module and want an extra digit, you can add another single digit display. If you want a ruler, the design files are here.
Connecting the MC14489 to an LED display isn’t complex at all. From the data sheet consider Figure 9 (click the image to enlarge):
Each of the anode control pins from the MC14489 connect to the matching anodes on your display module, and the BANK1~5 pins connect to the matching digit cathode pins on the display module. You can find the MC14489 pin assignments on page 1 of the data sheet. Seeing as this is chapter fifty-one - by now you should be confident with finding such information on the data sheets, so I will be encouraging you to do a little more of the work.
Interesting point – you don’t need current-limiting resistors. However you do need the resistor Rx – this controls the current flow to each LED segment. But which value to use? You need to find out the forward current of your LED display (for example 20 mA) then check Figure 7 on page 7 of the data sheet (click image to enlarge):
To be conservative I’m using a value of 2k0 for Rx, however you can choose your own based on the data sheet for your display and the graph above. Next – connect the data, clock and enable pins of the MC14489 to three Arduino digital pints – for our example we’re using 5, 6 and 7 for data, clock and enable respectively. Then it’s just 5V and GND to Arduino 5V and GND – and put a 0.1uF capacitor between 5V and GND. Before moving on double-check the connections – especially between the MC14489 and the LED display.
Controlling the MC14489
To control the display we need to send data to two registers in the MC14489 – the configuration register (one byte) and the display register (three bytes). See page 9 of the data sheet for the overview. The MC14489 will understand that if we send out one byte of data it is to send it the configuration register, and if it receives three bytes of data to send it to the display register. To keep things simple we’ll only worry about the first bit (C0) in the configuration register – this turns the display outputs on or off. To do this, use the following:
digitalWrite(enable, LOW); shiftOut(data, clock, MSBFIRST, B00000001); // used binary for clarity, however you can use decimal or hexadecimal numbers digitalWrite(enable, HIGH); delay(10);
and to turn it off, send bit C0 as zero. The small delay is necessary after each command.
Once you have turned the display on – the next step is to send three bytes of data which represent the numbers to display and decimal points if necessary. Review the table on page 8 of the data sheet. See how they have the binary nibble values for the digits in the third column. Thankfully the nibble for each digit is the binary value for that digit. Furthermore you might want to set the decimal point – that is set using three bits in the first nibble of the three bytes (go back to page 9 and see the display register). Finally you can halve the brightness by setting the very first bit to zero (or one for full brightness).
As an example for that – if you want to display 5.4321 the three bytes of data to send in binary will be:
1101 0101 0100 0011 0010 0001
Let’s break that down. The first bit is 1 for full brightness, then the next three bits (101) turn on the decimal point for BANK5 (the left-most digit). Then you have five nibbles of data, one for each of the digits from left to right. So there’s binary for 5, then four, then three, then two, then one.
digitalWrite(enable, LOW); shiftOut(data, clock, MSBFIRST, B11010101); // D23~D16 shiftOut(data, clock, MSBFIRST, B01000011); // D15~D8 shiftOut(data, clock, MSBFIRST, B00100001); // D7~D0 digitalWrite(enable, HIGH); delay(10);
To demonstrate everything described so far, it’s been neatly packaged into our first example sketch – Example 51.1:
// Example 51.1 // Motorola MC14489 with HP 5082-7415 5-digit, 7-segment LED display // 2k0 resistor on MC14489 Rx pin // John Boxall 2013 CC by-sa-nc
// define pins for data from Arduino to MC14489 // we treat it just like a 74HC595 int data = 5; int clock = 6; int enable = 7;
void setup()
{
pinMode(data, OUTPUT);
pinMode(enable, OUTPUT);
pinMode(clock, OUTPUT);
displayOn(); // display defaults to off at power-up
}
void displayTest1()
// displays 5.4321
{
digitalWrite(enable, LOW); // send 3 bytes to display register. See data sheet page 9
// you can also insert decimal or hexadecimal numbers in place of the binary numbers
// we're using binary as you can easily match the nibbles (4-bits) against the table
// in data sheet page 8
shiftOut(data, clock, MSBFIRST, B11010101); // D23~D16
shiftOut(data, clock, MSBFIRST, B01000011); // D15~D8
shiftOut(data, clock, MSBFIRST, B00100001); // D7~D0
digitalWrite(enable, HIGH);
delay(10);
}
void displayTest2()
// displays ABCDE
{
digitalWrite(enable, LOW); // send 3 bytes to display register. See data sheet page 9
// you can also insert decimal or hexadecimal numbers in place of the binary numbers
// we're using binary as you can easily match the nibbles (4-bits) against the table
// in data sheet page 8
shiftOut(data, clock, MSBFIRST, B10001010); // D23~D16
shiftOut(data, clock, MSBFIRST, B10111100); // D15~D8
shiftOut(data, clock, MSBFIRST, B11011110); // D7~D0
digitalWrite(enable, HIGH);
delay(10);
}
void displayOn()
// turns on display
{
digitalWrite(enable, LOW);
shiftOut(data, clock, MSBFIRST, B00000001);
digitalWrite(enable, HIGH);
delay(10);
}
void displayOff()
// turns off display
{
digitalWrite(enable, LOW);
shiftOut(data, clock, MSBFIRST, B00000000);
digitalWrite(enable, HIGH);
delay(10);
}
void loop()
{
displayOn();
displayTest1();
delay(1000);
displayTest2();
delay(1000);
displayOff();
delay(500);
}
… with the results in the following video:
Now that we can display numbers and a few letters with binary, life would be easier if there was a way to take a number and just send it to the display.
So consider the following function that takes an integer between 0 and 99999, does the work and sends it to the display:
void displayIntLong(long x)
// takes a long between 0~99999 and sends it to the MC14489
{
int numbers[5];
byte a=0;
byte b=0;
byte c=0; // will hold the three bytes to send to the MC14489
// first split the incoming long into five separate digits
numbers[0] = int ( x / 10000 ); // left-most digit (will be BANK5)
x = x % 10000;
numbers[1] = int ( x / 1000 );
x = x % 1000;
numbers[2] = int ( x / 100 );
x = x % 100;
numbers[3] = int ( x / 10 );
x = x % 10;
numbers[4] = x % 10; // right-most digit (will be BANK1)
// now to create the three bytes to send to the MC14489
// build byte c which holds digits 4 and 5
c = numbers[3];
c = c << 4; // move the nibble to the left
c = c | numbers[4];
// build byte b which holds digits 3 and 4
b = numbers [1];
b = b << 4;
b = b | numbers[2];
// build byte a which holds the brightness bit, decimal points and digit 1
a = B10000000 | numbers[0]; // full brightness, no decimal points
// now send the bytes to the MC14489
digitalWrite(enable, LOW);
shiftOut(data, clock, MSBFIRST, a);
shiftOut(data, clock, MSBFIRST, b);
shiftOut(data, clock, MSBFIRST, c);
digitalWrite(enable, HIGH);
delay(10);
}
So how does that work? First it splits the 5-digit number into separate digits and stores them in the array numbers[]. It then places the fourth digit into a byte, then moves the data four bits to the left – then we bitwise OR the fifth digit into the same byte. This leaves us with a byte of data containing the nibbles for the fourth and fifth digit. The process is repeated for digits 2 and 3. Finally the brightness bit and decimal point bits are assigned to another byte which then has the first digit’s nibble OR’d into it. Which leaves us with bytes a, b and c ready to send to the MC14489. Note that there isn’t any error-checking – however you could add a test to check that the number to be displayed was within the parameter, and if not either switch off the display (see example 51.1) or throw up all the decimal points or … whatever you want.
You can download the demonstration sketch for the function – Example 51.2, and view the results in the following video:
You can also display the letters A to F by sending the values 10 to 15 respectivel to each digit’s nibble. However that would be part of a larger application, which you can (hopefully) by now work out for yourself. Furthermore there’s some other characters that can be displayed – however trying to display the alphabet using 7-segment displays is somewhat passé. Instead, get some 16-segment LED modules or an LCD.
Finally, you can cascade more than one MC14489 to control more digits. Just run a connection from the data out pin on the first MC14889 to the data pin of the second one, and all the clock and enable lines together. Then send out more data – see page 11 of the data sheet. If you’re going to do that in volume other ICs may be a cheaper option and thus lead you back to the MAX7219.
Conclusion
For a chance find the MC14489 is a fun an inexpensive way to drive those LED digit displays. We haven’t covered every single possible option or feature of the part – however you will now have the core knowledge to go further with the MC14489 if you need to move further with it. And if you enjoy my tutorials, or want to introduce someone else to the interesting world of Arduino – check out my new book “Arduino Workshop” from No Starch Press.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, 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.
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 tronixstuff.com. Why not follow things on twitter, Google+, 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.
Tutorial – Arduino and ILI9325 colour TFT LCD modules
Learn how to use inexpensive ILI9325 colour TFT LCD modules in chapter fifty of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.
Introduction
Colour TFT LCD modules just keep getting cheaper, so in this tutorial we’ll show you how to get going with some of the most inexpensive modules we could find. The subject of our tutorial is a 2.8″ 240 x 320 TFT module with the ILI9325 LCD controller chip. If you look in ebay this example should appear pretty easily, here’s a photo of the front and back to help identify it:
There is also the line “HY-TFT240_262k HEYAODZ110510″ printed on the back of the module. They should cost less than US$10 plus shipping. Build quality may not be job number one at the factory so order a few, however considering the cost of something similar from other retailers it’s cheap insurance. You’ll also want sixteen male to female jumper wires to connect the module to your Arduino.
Getting started
To make life easier we’ll use an Arduino library “UTFT” written for this and other LCD modules. It has been created by Henning Karlsen and can be downloaded from his website. If you can, send him a donation – this library is well worth it. Once you’ve downloaded and installed the UTFT library, the next step is to wire up the LCD for a test.
Run a jumper from the following LCD module pins to your Arduino Uno (or compatible):
- DB0 to DB7 > Arduino D0 to D7 respectively
- RD > 3.3 V
- RSET > A2
- CS > A3
- RW > A4
- RS > A5
- backlight 5V > 5V
- backlight GND > GND
Then upload the following sketch – Example 50.1. You should be presented with the following on your display:
If you’re curious, the LCD module and my Eleven board draws 225 mA of current. If that didn’t work for you, double-check the wiring against the list provided earlier. Now we’ll move forward and learn how to display text and graphics.
Sketch preparation
You will always need the following before void setup():
#include "UTFT.h"
UTFT myGLCD(ILI9325C,19,18,17,16); // for Arduino Uno
and in void setup():
myGLCD.InitLCD(orientation); myGLCD.clrScr();
with the former command, change orientation to either LANDSCAPE to PORTRAIT depending on how you’ll view the screen. You may need further commands however these are specific to features that will be described below. The function .clrScr() will clear the screen.
Displaying Text
There are three different fonts available with the library. To use them add the following three lines before void setup():
extern uint8_t SmallFont[]; extern uint8_t BigFont[]; extern uint8_t SevenSegNumFont[];
When displaying text you’ll need to define the foreground and background colours with the following:
myGLCD.setColor(red, green, blue); myGLCD.setBackColor(red, green, blue);
Where red, green and blue are values between zero and 255. So if you want white use 255,255,255 etc. For some named colours and their RGB values, click here. To select the required font, use one of the following:
myGLCD.setFont(SmallFont); // Allows 20 rows of 40 characters
myGLCD.setFont(BigFont); // Allows 15 rows of 20 characters
myGLCD.setFont(SevenSegNumFont); // allows display of 0 to 9 over four rows
Now to display the text use the function:
myGLCD.print("text to display",x, y);
where text is what you’d like to display, x is the horizontal alignment (LEFT, CENTER, RIGHT) or position in pixels from the left-hand side of the screen and y is the starting point of the top-left of the text. For example, to start at the top-left of the display y would be zero. You can also display a string variable instead of text in inverted commas.
You can see all this in action with the following sketch – Example 50.2, which is demonstrated in the following video:
Furthremore, you can also specify the angle of display, which gives a simple way of displaying text on different slopes. Simply add the angle as an extra parameter at the end:
myGLCD.print(“Hello, world”, 20, 20, angle);
Again, see the following sketch – Example 50.2a, and the results below:
Displaying Numbers
Although you can display numbers with the text functions explained previously, there are two functions specifically for displaying integers and floats.
You can see these functions in action with the following sketch – Example 50.3, with an example of the results below:
Displaying Graphics
There’s a few graphic functions that can be used to create required images. The first is:
myGLCD.fillScr(red, green, blue);
which is used the fill the screen with a certain colour. The next simply draws a pixel at a specified x,y location:
myGLCD.drawPixel(x,y);
Remember that the top-left of the screen is 0,0. Moving on, to draw a single line, use:
myGLCD.drawLine(x1,0,x2,239);
where the line starts at x1,y1 and finishes at x2,y2. Need a rectangle? Use:
myGLCD.drawRect(x1,y2,x2,y2); // for open rectangles
myGLCD.fillRect(x1,y2,x2,y2); // for filled rectangles
where the top-left of the rectangle is x1,y1 and the bottom-right is x2, y2. You can also have rectangles with rounded corners, just use:
myGLCD.drawRoundRect(x1,y2,x2,y2); // for open rectangles
myGLCD.fillRoundRect(x1,y2,x2,y2); // for filled rectangles
instead. And finally, circles – which are quite easy. Just use:
myGLCD.drawCircle(x,y,r); // draws open circle myGLCD.fillCircle(x,y,r); // draws a filled circle
where x,y are the coordinates for the centre of the circle, and r is the radius. For a quick demonstration of all the graphic functions mentioned so far, see Example 50.4 – and the following video:
Displaying bitmap images
If you already have an image in .gif, .jpg or .png format that’s less than 300 KB in size, this can be displayed on the LCD. To do so, the file needs to be converted to an array which is inserted into your sketch. Let’s work with a simple example to explain the process. Below is our example image:
Save the image of the puppy somewhere convenient, then visit this page. Select the downloaded file, and select the .c and Arduino radio buttons, then click “make file”. After a moment or two a new file will start downloading. When it arrives, open it with a text editor – you’ll see it contains a huge array and another #include statement – for example:
Past the #include statement and the array into your sketch above void setup(). After doing that, don’t be tempted to “autoformat” the sketch in the Arduino IDE. Now you can use the following function to display the bitmap on the LCD:
myGLCD.drawBitmap(x,y,width,height, name, scale);
Where x and y are the top-left coordinates of the image, width and height are the … width and height of the image, and name is the name of the array. Scale is optional – you can double the size of the image with this parameter. For example a value of two will double the size, three triples it – etc. The function uses simple interpolation to enlarge the image, and can be a clever way of displaying larger images without using extra memory. Finally, you can also display the bitmap on an angle – using:
myGLCD.drawBitmap(x,y,width,height, name, angle, cx, cy);
where angle is the angle of rotation and cx/cy are the coordinates for the rotational centre of the image.
The bitmap functions using the example image have been used in the following sketch – Example 50.5, with the results in the following video:
Unfortunately the camera doesn’t really do the screen justice, it looks much better with the naked eye.
Running out of space or I/O? Use an Arduino Mega
By now you may have noticed that the library for the LCDs uses up a fair amount of memory, which could be a problem. And using bitmaps eats up memory as well. And the I/O requirements are quite heavy. The solution is to use an Arduino Mega or compatible board – as they have up to eight times the sketch memory available. However the wiring is a little different – so when using a Mega, run a jumper from the following LCD module pins to your Mega (or compatible):
- DB0 to DB7 > Mega D22 to D29 respectively
- RD > 3.3 V
- RSET > D41
- CS > D40
- RW > D39
- RS > D38
- backlight 5V > 5V
- backlight GND > GND
You will also need to change the line
UTFT myGLCD(ILI9325C,19,18,17,16); // for Uno
to
UTFT myGLCD(ILI9325C,38,39,40,41); // for Mega
What about the SD card socket and touch screen?
The SD socket didn’t work, and I won’t be working with the touch screen at this time.
Conclusion
So there you have it – an incredibly inexpensive and possibly useful LCD module. Thank you to Henning Karlsen for his useful library, and if you found it useful – send him a donation via his page.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, 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.
Review – Schmartboard SMT Boards
In this article we review a couple of SMT prototyping boards from Schmartboard.
Introduction
Sooner or later you’ll need to use a surface-mount technology component. Just like taxes and myki* not working, it’s inevitable. When the time comes you usually have a few options – make your own PCB, then bake it in an oven or skillet pan; get the part on a demo board from the manufacturer (expensive); try and hand-solder it yourself using dead-bug wiring or try to mash it into a piece of strip board; or find someone else to do it. Thanks to the people at Schmartboard you now have another option which might cost a few dollars more but guarantees a result. Although they have boards for almost everything imaginable, we’ll look at two of them – one for QFP packages and their Arduino shield that has SOIC and SOP23-6 areas.
QFP 32-80 pin board
In our first example we’ll see how easy it is to prototype with QFP package ICs. An example of this is the Atmel ATmega328 microcontroller found on various Arduino-compatible products, for example:
Although our example has 32 pins, the board can handle up to 80-pin devices. You simply place the IC on the Schmartboard, which holds the IC in nicely due to the grooved tracks for the pins:
The tracks are what makes the Schmartboard EZ series so great – they help hold the part in, and contain the required amount of solder. I believe this design is unique to Schmartboard and when you look in their catalogue, select the “EZ” series for this technology. Moving forward, you just need some water-soluble flux:
then tack down the part, apply flux to the side you’re going to solder – then slowly push the tip of your soldering iron (set to around 750 degrees F) down the groove to the pin. For example:
Then repeat for the three other sides. That’s it. If your part has an exposed pad on the bottom, there’s a hole in the centre of the Schmartboad that you can solder into as well:
After soldering I really couldn’t believe it worked, so probed out the pins to the breakout pads on the Schmartboard to test for shorts or breaks – however it tested perfectly. The only caveat is that your soldering iron tip needs to be the same or smaller pitch than the the part you’re using, otherwise you could cause a solder bridge. And use flux! You need the flux. After soldering you can easily connect the board to the rest of your project or build around it.
Schmartboard Arduino shield
There’s also a range of Arduino shields with various SMT breakout areas, and we have the version with 1.27mm pitch SOIC and a SOT23-6 footprint. SOIC? For example:
This is the AD5204 four-channel digital potentiometer we used in the SPI tutorial. It sits nicely in the shield and can be easily soldered onto the board. Don’t forget the flux! Although the SMT areas have the EZ-technology, I still added a little solder of my own – with satisfactory results:
The SOT23-6 also fits well, with plenty of space for soldering it in. SOT23? Example – the ADS1110 16-bit ADC which will be the subject of a future tutorial:
Working with these tiny components is also feasible but requires a finer iron tip and a steady hand.
Once the SMT component(s) have been fitted, you can easily trace out the matching through-hole pads for further connections. The shield matches the Arduino R3 standards and includes stacking header sockets, two LEDs for general use, space and parts for an RC reset circuit, and pads to add pull-up resistors for the I2C bus:
Finally there’s also three 0805-sized parts and footprints for some practice or use. It’s a very well though-out shield and should prove useful. You can also order a bare PCB if you already have stacking headers to save money.
Conclusion
If you’re in a hurry to prototype with SMT parts, instead of mucking about – get a Schmartboard. They’re easy to use and work well. Full-sized images available on flickr.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
The boards used in this article were a promotional consideration supplied by Schmartboard.
Review – LBE “Magpie” Arduino-compatible board
In this article we review the “Magpie” Arduino Uno-compatible board from Little Bird Electronics.
Introduction
Finally I’m back at the office and have a pile of things to write about. Starting with the subject of this review – the “Magpie” board from Little Bird Electronics in Australia. It seems that a new Arduino-compatible board enters the market every week, thanks to the open-source nature of the platform and the availability of rapid manufacturing. However the Magpie isn’t just any old Arduino Uno knock-off, it has something which helps it stand out from the crowd – status LEDs on every digital and analogue I/O pin. You can see them between the stacking header sockets and the silk-screen labels. For example:
and for the curious, the bottom of the Magpie:
At first glance you might think “why’d they bother doing that? I could just wire up some LEDs myself”. True. However having them on the board speeds up the debugging process as you can see when an output is HIGH or LOW – and in the case of an input pin, whether a current is present or not. For the curious the LEDs are each controlled by a 2N7002 MOSFET with the gate connected to the I/O pin, for example:
An LED will illuminate as long as the gate voltage is higher than the threshold voltage – no matter the status of the particular I/O pin. And if an I/O pin is left floating it may trigger the LED if the threshold voltage is exceeded at the gate. Therefore when using the Magpie it would be a good idea to set all the pins to LOW that aren’t required for your particular sketch. Even if you remove and reapply power the floating will still be prevalent, and indicated visually – for example:
Nevertheless you can sort that out in void setup(), and then the benefits of the LEDs become apparent. Consider the following quick demonstration sketch:
// LBE Magpie board LED demo - John Boxall 18 March 2013
// usual blink delay period
int d=100;
void setup()
{
// digital pins to outputs
for (int a=0; a<14; a++)
{
pinMode(a, OUTPUT);
}
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
}
void allOn()
// all LEDs on
{
for (int a=0; a<14; a++)
{
digitalWrite(a, HIGH);
}
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);
digitalWrite(A4, HIGH);
digitalWrite(A5, HIGH);
}
void allOff()
// all LEDs on
{
for (int a=0; a<14; a++)
{
digitalWrite(a, LOW);
}
digitalWrite(A0, LOW);
digitalWrite(A1, LOW);
digitalWrite(A2, LOW);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, LOW);
}
void clockWise(int r, int s)
// blinks on and off each LED clockwise
// r - # rotations, s - blink delay
{
allOff();
for (int a=0; a<r; a++)
{
for (int b=13; b>=0; --b)
{
digitalWrite(b, HIGH);
delay(s);
digitalWrite(b, LOW);
}
digitalWrite(A5, HIGH);
delay(s);
digitalWrite(A5, LOW);
digitalWrite(A4, HIGH);
delay(s);
digitalWrite(A4, LOW);
digitalWrite(A3, HIGH);
delay(s);
digitalWrite(A3, LOW);
digitalWrite(A2, HIGH);
delay(s);
digitalWrite(A2, LOW);
digitalWrite(A1, HIGH);
delay(s);
digitalWrite(A1, LOW);
digitalWrite(A0, HIGH);
delay(s);
digitalWrite(A0, LOW);
delay(s);
}
}
void anticlockWise(int r, int s)
// blinks on and off each LED anticlockwise
// r - # rotations, s - blink delay
{
allOff();
for (int a=0; a<r; a++)
{
for (int b=0; b<14; b++)
{
digitalWrite(b, HIGH);
delay(s);
digitalWrite(b, LOW);
}
digitalWrite(A0, HIGH);
delay(s);
digitalWrite(A0, LOW);
digitalWrite(A1, HIGH);
delay(s);
digitalWrite(A1, LOW);
digitalWrite(A2, HIGH);
delay(s);
digitalWrite(A2, LOW);
digitalWrite(A3, HIGH);
delay(s);
digitalWrite(A3, LOW);
digitalWrite(A4, HIGH);
delay(s);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
delay(s);
digitalWrite(A5, LOW);
delay(s);
}
}
void loop()
{
anticlockWise(3,50);
clockWise(3,50);
for (int z=0; z<4; z++)
{
allOn();
delay(100);
allOff();
delay(100);
}
}
… and the results are demonstrated in the following video:
Apart from the LEDs the Magpie offers identical function to that of an Arduino Uno R2 – except the USB microcontroller is an Atmel 16U2 instead of an 8U2, and the USB socket is a mini-USB and not the full-size type. For the curious you can download the Magpie design files from the product page.
Conclusion
If you’re often experimenting or working with the Arduino’s I/O pins and find yourself wiring up LEDs for testing purposes – the Magpie was made for you. Having those LEDs on the board really does save you if in a hurry to test or check something.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
The Magpie board used in this article was a promotional consideration supplied by Little Bird Electronics.
Introducing Goldilocks – the Arduino Uno-compatible with 1284p and uSD card
[Update 19/03/2013 - the project is now fully funded. When the boards arrive we'll do a full review]
Introduction
It’s a solid fact that there are quite a few variations on the typical Arduino Uno-compatible board. You can get them with onboard wireless, GSM, Zigbee and more – however all with their own issues and specific purposes. But what if you wanted a board that was physically and electrically compatible with an Arduino Uno – but with much more SRAM, more EEPROM, more flash, more speed – and then some? Well that (hopefully) will be a possibility with the introduction of the “Goldilocks” board on Pozible by Phillip Stevens.
What’s Pozible?
Pozible is the Australian version of Kickstarter. However just like KS anyone with a credit card or PayPal can pledge and support projects.
What’s a Goldilocks board?
It’s a board based around the Atmel ATmega1284p microcontroller in an Arduino Uno-compatible physical board with a microSD card socket and a few extras. The use of the ’1284p gives us the following advantages over the Arduino Uno, including:
- 16 kByte SRAM = 8x Uno SRAM – so that’s much more space for variables used in sketches – great for applications that use larger frame buffers such as Ethernet and image work;
- 2 kByte EEPROM = 2 x Uno EEPROM – giving you more space for non-volatile data storage on the main board;
- 128 kByte flash memory = 4 x Uno – giving you much, much more room for those larger sketches;
- Two programmable USARTS – in other words, two hardware serial ports – no mucking about with SoftwareSerial and GSM or GPS shields;
- Timer 3 – the ’1284p microcontroller has an extra 16-bit timer – timer 3, that is not present on any other ATmega microcontroller. Timer 3 does not have PWM outputs (unlike Timer 0, Timer 1, and Timer 2), and therefore is free to use as a powerful internal Tick counter, for example in a RTOS. freeRTOS has already been modified to utilise this Timer 3;
- JTAG interface – yes – allowing more advanced developers the opportunity to debug their code;
- better PWM access – the 1284p brings additional 8-bit Timer 2 PWM outputs onto PD, which creates the option for 2 additional PWM options on this port. It also removes the sharing of the important 16-bit PWM pins with the SPI interface, by moving them to PD4 & PD5, thus simplifying interface assignments;
- Extra I/O pins – the 1284p has additional digital I/O pins on the PB port. These pins could be utilised for on-board Slave Select pins (for example), without stealing on-header digital pins and freeing the Arduino Pin 10 for Shield SPI SS use exclusively;
Furthermore the following design improvements over an Arduino Uno:
- adding through-holes for all I/O – allowing you to solder directly onto the board whilst keeping header sockets;
- replicate SPI and I2C for ease of use;
- microSD card socket – that’s a no-brainer;
- link the ATmega16u2 and ATmega1284p SPI interfaces – this will allow the two devices to work in concert for demanding multi-processing applications, involving USB and other peripherals;
- Fully independent analogue pins, including seperate AVCC and GND – helps reduce noise on the ADC channels for improved analogue measurement accuracy;
- move the reset button to the edge of the board – another no-brainer
- clock the board at 20 MHz – that’s an extra 4 MHz over a Uno. And the use of a through hole precision crystal (not a SMD resonator) allows the use of after market timing choices, eg 22.1184 MHz for more accurate UART timings.
What does it look like?
At the moment the board mock-up looks like this:
If funding is successful (and we hope it will be) the Goldilocks will be manufactured by the team at Freetronics. Apart from being a world-leader in Arduino-compatible hardware and systems, they’re the people behind the hardware for Ardusat and more – so we know the Goldilocks will be in good hands.
Will it really be compatible?
Yes – the Goldilocks will be shipped pre-programmed with an Arduino compatible boot-loader, and the necessary Board description files will be available to provide a 100% compatible Arduino IDE experience.
Conclusion
If you think this kind of board would be useful in your projects, you want to support a good project – or both, head over to Pozible and make your pledge. And for the record – I’ve put my money where my mouth is
Please note that I’m not involved in nor responsible for the Goldilocks project, however I’m happy to promote it as a worthwhile endeavour. In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, 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.
Project: Clock Four – Scrolling text clock
Introduction
Time for another instalment in my highly-irregular series of irregular clock projects. In this we have “Clock Four” – a scrolling text clock. After examining some Freetronics Dot Matrix Displays in the stock, it occurred to me that it would be neat to display the time as it was spoken (or close to it) – and thus this the clock was born. It is a quick project – we give you enough to get going with the hardware and sketch, and then you can take it further to suit your needs.
Hardware
You’ll need three major items – An Arduino Uno-compatible board, a real-time clock circuit or module using either a DS1307 or DS3232 IC, and a Freetronics DMD. You might want an external power supply, but we’ll get to that later on.
The first stage is to fit your real-time clock. If you are unfamiliar with the operation of real-time clock circuits, check out the last section of this tutorial. You can build a RTC circuit onto a protoshield or if you have a Freetronics Eleven, it can all fit in the prototyping space as such:
If you have an RTC module, it will also fit in the same space, then you simply run some wires to the 5V, GND, A4 (for SDA) and A5 (for SCL):
By now I hope you’re thinking “how do you set the time?”. There’s two answers to that question. If you’re using the DS3232 just set it in the sketch (see below) as the accuracy is very good, you only need to upload the sketch with the new time twice a year to cover daylight savings (unless you live in Queensland). Otherwise add a simple user-interface – a couple of buttons could do it, just as we did with Clock Two. Finally you just need to put the hardware on the back of the DMD. There’s plenty of scope to meet your own needs, a simple solution might be to align the control board so you can access the USB socket with ease – and then stick it down with some Sugru:
With regards to powering the clock – you can run ONE DMD from the Arduino, and it runs at a good brightness for indoor use. If you want the DMD to run at full, retina-burning brightness you need to use a separate 5 V 4 A power supply. If you’re using two DMDs – that goes to 8 A, and so on. Simply connect the external power to one DMD’s terminals (connect the second or more DMDs to these terminals):

The Arduino Sketch
You can download the sketch from here. It was written only for Arduino v1.0.1. The sketch has the usual functions to set and retrieve the time from DS1307/3232 real-time clock ICs, and as usual with all our clocks you can enter the time information into the variables in void setup(), then uncomment setDateDs1307(), upload the sketch, re-comment setDateDs1307, then upload the sketch once more. Repeat that process to re-set the time if you didn’t add any hardware-based user interface.
Once the time is retrieved in void loop(), it is passed to the function createTextTime(). This function creates the text string to display by starting with “It’s “, and then determines which words to follow depending on the current time. Finally the function drawText() converts the string holding the text to display into a character variable which can be passed to the DMD.
And here it is in action:
Conclusion
This was a quick project, however I hope you found it either entertaining or useful – and another random type of clock that’s easy to reproduce or modify yourself. We’re already working on another one which is completely different, so stay tuned.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, 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.
Arduino and KTM-S1201 LCD modules
Learn how to use very inexpensive KTM-S1201 LCD modules in this edition of our Arduino tutorials. This is chapter forty-nine of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.
Introduction
After looking for some displays to use with another (!) clock, I came across some 12-digit numeric LCD displays. They aren’t anything flash, and don’t have a back light – however they were one dollar each. How could you say no to that? So I ordered a dozen to try out. The purpose of this tutorial is to show you how they are used with an Arduino in the simplest manner possible.
Moving forward – the modules look like OEM modules for desktop office phones from the 1990s:
With a quick search on the Internet you will find a few sellers offering them for a dollar each. The modules (data sheet) use the NEC PD7225 controller IC (data sheet):
They aren’t difficult to use, so I’ll run through set up and operation with a few examples.
Hardware setup
First you’ll need to solder some sort of connection to the module – such as 2×5 header pins. This makes it easy to wire it up to a breadboard or a ribbon cable:
The rest of the circuitry is straight-forward. There are ten pins in two rows of five, and with the display horizontal and the pins on the right, they are numbered as such:
Now make the following connections:
- LCD pin 1 to 5V
- LCD pin 2 to GND
- LCD pin 3 to Arduino D4
- LCD pin 4 to Arduino D5
- LCD pin 5 to Arduino D6
- LCD pin 6 to Arduino D7
- LCD pin 7 – not connected
- LCD pin 8 – Arduino D8
- LCD pin 9 to the centre pin of a 10k trimpot – whose other legs connect to 5V and GND. This is used to adjust the contrast of the LCD.
The Arduino digital pins that are used can be changed – they are defined in the header file (see further on). If you were curious as to how low-current these modules are:
That’s 0.689 mA- not bad at all. Great for battery-powered operations. Now that you’ve got the module wired up, let’s get going with some demonstration sketches.
Software setup
The sketches used in this tutorial are based on work by Jeff Albertson and Robert Mech, so kudos to them – however we’ve simplified them a little to make use easier. We’ll just cover the functions required to display data on the LCD. However feel free to review the sketches and files along with the controller chip datasheet as you’ll get an idea of how the controller is driven by the Arduino.
When using the LCD module you’ll need a header file in the same folder as your sketch. You can download the header file from here. Then every time you open a sketch that uses the header file, it should appear in a tab next to the main sketch, for example (click to enlarge):
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
ktmWriteString();
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:
ktmCommand(_ClearDsp);
Next – to individually place digits on the screen, use the function:
ktmPrnNumb(n,p,d,l);
Where n is the number to be displayed (zero or a positive integer), p is the position on the LCD for the number’s (the positions from left to right are 11 to 0…), d is the number of digits to the right of the decimal point (leave as zero if you don’t want a decimal point), and l is the number of digits being displayed for n. When you display digits using this function you can use more than one function to compose the number to be displayed – as this function doesn’t clear the screen.
To help get your head around it, the following example sketch (download) has a variety of examples in void loop(). You can watch this example in the following video:
Conclusion
So there you have it – an incredibly inexpensive and possibly useful LCD module. Thank you to Jeff Albertson and Robert Mech for their help and original code.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, 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.
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.
Introduction
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.
Also – a few months ago – we received the new Freescale Freedom FRDM-KL25Z development board from element14. I started to write about using the board but frankly it did my head in, as at the time the IDE was almost a one gigabyte download and the learning curve too steep for the time I had available. Which was a pity as the board is inexpensive and quite powerful. So the board went into the “miscellaneous dev kit” box graveyard. Until now. Why?
You can now use the Freedom board with mbed.
It isn’t perfect – yet – but 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 (click to enlarge):
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. How inexpensive? In Australia it’s $9 plus GST and delivery.
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. Note that the board ships without any stacking header sockets, but element14 have a starter pack with those and a USB cable for $16.38++.
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:
- Download and install the USB drivers for Windows or Linux from here.
- Visit mbed.org and create a user account. Check your email for the confirmation link and follow the instructions within.
- Plug in your Freedom board – using the USB socket labelled “OpenSDA”. It will appear as a disk called “bootloader”
- Download this file and copy it onto the “bootloader” drive
- Unplug the Freedom board, wait a moment – then plug it back in. It should now appear as a disk called “MBED”, for example (click to enlarge):
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 (click to enlarge):
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:
#include "mbed.h"
DigitalOut pulsepin(PTA13);
int main() {
while(1) {
pulsepin = 1;
wait(1);
pulsepin = 0;
wait(1);
}
}
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 (click to enlarge):
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.
Conclusion
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.
The Freescale Freedom FRDM-KL25Z development board used in this article was a promotional consideration supplied by element14.






















































