Tag Archive | "colour"

Tutorial – Arduino and Color LCD

Learn how to use an inexpensive colour LCD shield with your Arduino. This is chapter twenty-eight of our huge Arduino tutorial series.

Updated 03/02/2014

There are many colour LCDs on the market that can be used with an Arduino, and for this tutorial we’re using a relatively simple model available that is available from suppliers such as Tronixlabs, based on a small LCD originally used in Nokia 6100 mobile phones:

Arduino Color LCD shield

These are a convenient and inexpensive way of displaying data, or for monitoring variables when debugging a sketch. Before getting started, a small amount of work is required.

From the two examples we have seen, neither of them arrive fitted with stacking headers (or in Sparkfun’s case – not included) or pins, so before doing anything you’ll need to fit your choice of connector. Although the LCD shield arrived with stacking headers, we used in-line pins as another shield would never be placed on top:

Arduino Color LCD shield fit headers

Which can easily be soldered to the shield in a few minutes:

Arduino Color LCD shield fitted

 While we’re on the subject of pins – this shield uses D3~D5 for the three buttons, and D8, 9, 11 and 13 for the LCD interface. The shield takes 5V and doesn’t require any external power for the backlight. The LCD module has a resolution of 128 x 128 pixels, with nine defined colours (red, green, blue, cyan, magenta, yellow, brown, orange, pink) as well as black and white.

So let’s get started. From a software perspective, the first thing to do is download and install the library for the LCD shield. Visit the library page here. Then download the .zip file, extract and copy the resulting folder into your ..\arduino-1.0.x\libraries folder. Be sure to rename the folder to “ColorLCDShield“. Then restart the Arduino IDE if it was already open.

At this point let’s check the shield is working before moving forward. Once fitted to your Arduino, upload the ChronoLCD_Color sketch that’s included with the library, from the IDE Examples menu:

Arduino Color LCD shield example sketch

This will result with a neat analogue clock you can adjust with the buttons on the shield, as shown in this video.

It’s difficult to photograph the LCD – (some of them have very bright backlights), so the image may not be a true reflection of reality. Nevertheless this shield is easy to use and we will prove this in the following examples. So how do you control the color LCD shield in your sketches?

At the start of every sketch, you will need the following lines:

as well as the following in void setup():

With regards to lcd.init(), try it first without a parameter. If the screen doesn’t work, try EPSON instead. There are two versions of the LCD shield floating about each with a different controller chip. The contrast parameter is subjective, however 63 looks good – but test for yourself.

Now let’s move on to examine each function with a small example, then use the LCD shield in more complex applications.

The LCD can display 8 rows of 16 characters of text. The function to display text is:

where x and y are the coordinates of the top left pixel of the first character in the string. Another necessary function is:

Which clears the screen and sets the background colour to the parameter colour.  Please note – when referring to the X- and Y-axis in this article, they are relative to the LCD in the position shown below. Now for an example – to recreate the following display:

Arduino Color LCD shield text demonstration

… use the following sketch:

In example 28.1 we used the function lcd.clear(), which unsurprisingly cleared the screen and set the background a certain colour.

Let’s have a look at the various background colours in the following example. The lcd.clear()  function is helpful as it can set the entire screen area to a particular colour. As mentioned earlier, there are the predefined colours red, green, blue, cyan, magenta, yellow, brown, orange, pink, as well as black and white. Here they are in the following example:

And now to see it in action. In this demonstration video the colours are more livid in real life, unfortunately the camera does not capture them so well.

 

Now that we have had some experience with the LCD library’s functions, we can move on to drawing some graphical objects. Recall that the screen has a resolution of 128 by 128 pixels. We have four functions to make use of this LCD real estate, so let’s see how they work. The first is:

This function places a pixel (one LCD dot) at location x, y with the colour of colour.

Note – in this (and all the functions that have a colour parameter) you can substitute the colour (e.g. BLACK) for a 12-bit RGB value representing the colour required. Next is:

Which draws a line of colour COLOUR, from position x0, y0 to x1, y1. Our next function is:

This function draws an oblong or square of colour COLOUR with the top-left point at x0, y0 and the bottom right at x1, y1. Fill is set to 0 for an outline, and 1 for a filled oblong. It would be convenient for drawing bar graphs for data representation. And finally, we can also create circles, using:


X and Y is the location for the centre of the circle, radius and COLOUR are self-explanatory. We will now use these graphical functions in the following demonstration sketch:

The results of this sketch are shown in this video. For photographic reasons, I will stick with white on black for the colours.

So now you have an explanation of the functions to drive the screen – and only your imagination is holding you back.

Conclusion

Hopefully this tutorial is of use to you. and you’re no longer wondering “how to use a color LCD with Arduino”. They’re available from our tronixlabs store. 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 third printing!) “Arduino Workshop”.

visit tronixlabs.com

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, 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 arduino, LCD, LCD-09363, Linksprite, SHD_LCD_NOKIA, sparkfun, tronixstuff, tutorialComments (0)

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():

and in void setup():

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():

When displaying text you’ll need to define the foreground and background colours with the following:

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:

Now to display the text use the function:

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:

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:

example50p3

Displaying Graphics

There’s a few graphic functions that can be used to create required images. The first is:.

which is used the fill the screen with a certain colour. The next simply draws a pixel at a specified x,y location:

Remember that the top-left of the screen is 0,0. Moving on, to draw a single line, use:

where the line starts at x1,y1 and finishes at x2,y2. Need a rectangle? Use:

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:

instead. And finally, circles – which are quite easy. Just use:

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:

jrt3030

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:

cfile

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:

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:

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.

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.

LEDborder

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

Posted in arduino, bitmap, display, ILI9325, LCD, lesson, mega, TFT, tronixstuff, tutorialComments (45)

Kit Review – akafugu TWILCD Display Controller Backpacks

Introduction

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.

Assembly

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

with

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:


and

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:

Conclusion

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 akafugu.jp, however the opinions stated are purely my own.

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

Translated version in Serbo-Croatian language.

Posted in akafugu, arduino, clocks, I2C, kit review, LCD, part review, rgbComments (0)

Arduino Game: Tic-Tac-Toe

[Updated 19/02/2013]

Let’s recreate the game of Tic-tac-toe with our Arduino systems. This game is also known as Noughts and Crosses or Three-in-a-row. Whatever we call it, I’m sure you will be familiar with the game from your childhood or general messing about. For the uninitiated, there is an excellent explanation of the game over at Wikipedia.

tttboard

In the following examples, a human will play against the machine (Arduino). The demonstration sketches are almost identical except for one function – machineMove();. This function contains the method of deciding a move for the machine. By localising the machine’s decision making into that function we can experiment with levels of intelligence without worrying about the rest of the sketch. In writing this article it is assumed the reader has some basic Arduino or programming experience. If not, perhaps read some of my Arduino tutorials indexed here.

However first we will examine the hardware. I have used my well-worn Freetronics Eleven board, which is equivalent to the Arduino Uno. For a display, the Sparkfun LCD shield is used. For user input we have two buttons connected to digital pins 6 and 7, using 10k pull-down resistors as normal. The buttons are wired via a ScrewShield set. To save time I have used my generic button-board, whose schematic is below:

example12p3schematic

 

If you were to construct a more permanent example, this could be easily done. One could possibly use a DS touch-screen over their LCD. Perhaps for mark II? Nevertheless, time to move on. Now to explain how the sketch works – please download a copy from here so you can follow along with the explanation.

I have tried to make the sketch as modular as possible to make it easy to follow and modify. The sketch itself is relatively simple. We use an array board[] to map the pieces of the game board in memory – board[0] being the top-left and board[8] being the bottom-right position. We create a graphical representation of the board by drawing rectangles for the horizontal and vertical lines, lines to form crosses, and circles for … circles. The function drawBoard(); takes care of the board lines and calls drawPiece(); to place the players’ pieces. drawBoard(); reads the board[] array to determine if a position is blank (zero), a nought (1) or a cross (2).

The flow of the sketch is easy to follow. First the function introScreen() is called – it displays the introductory screen. Then drawBoard() is called to draw the initially-blank game board. Then the main function playGame(); is called. We have a global variable winner, whose value determine the winner of the game (0 – game still in play, 1 – human, 2 – machine, 3 – draw). playGame(); and other functions will refer to winner throughout the sketch. Within playGame();, the human and machine take turns placing their pieces. The function humanMove(); accepts the human’s choice in piece position, storing it into board[], and not allowing false moves. The function machineMove(); controls the decision-making process for the machine’s moves. In the first example, the machine moves by randomly selecting a board position. If the position is taken, another random position is selected (and so on) until a valid move can be made.

After each instance of humanMove(); and machineMove();, the function checkWinner(); is called. This function compares the contents of the array board[] against all possible scenarios for a win by either player, and calls the function drawTest(); – which checks for a draw – and stores the result in the variable winner as described earlier. Checking for a win is simple, however checking for a draw was a little more complex. This involves counting the number of 1s and 2s in the board[] array. If there are five 1s and four 2s or four 1s and five 2s ( in other words, the board is full) there is a draw. Easy!

If, after the function checkWinner(); is called, the varible winner >0 – then something to end the game has happened – either a win or a draw. This is determined using the switch…case function at the end of checkWinner();. At this point a function relative to the game status is called, each of which display the outcome and wait for the user to press button A to start a new game. At the end of each of these functions, we call the function clearBoard(); – which resets the array board[] and winner back to zero, ready for the next battle of wits.

Now for our first example in action. The function machineMove() is an example of the simplest form of play – the machine randomly selects blank positions on the board until the game ends. In the following video clip you can see this in action:

For the forthcoming examples, we will allow the choice of who moves first. This is accomplished with the function moveFirst(); which sets the variable whofirst to 1 for human first, or 2 for machine first. This is read by playGame() to determine the first move. Now let’s inject some strategy into our machineMove(); function to give the machine a slight edge above sheer randomness.

In the following example, the machine will first only use the centre or corners until those positions have been taken. This is accomplished by placing the position numbers into another array strategy1[]={0,2,4,6,8} which the machine will randomly select from until those positions are used.  Once all those positions have been filled, the machine will revert to random positioning to attempt a win. You can download this example sketch from here. Do you think the machine can win if allowed to move first? Let’s see what happens in the following video clip:

In the second example the player who moves first will generally have the advantage. From this point, how could we strengthen the machine’s level of intelligence to improve its strategy? If you have a better method, and can integrate it into the example sketch, and are happy to publish it under Creative Commons – email the sketch to john at tronixstuff dot com.

So there you have it, some variations on a classic game translated for our Arduino systems. I hope you found it interesting… or at least something different to read about.

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

Posted in arduino, education, games, LCD-09363, lesson, microcontrollers, tutorialComments (4)

Tutorial: Arduino and Colour LCD

Learn how to use the colour LCD shield from Sparkfun in chapter twenty-eight 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 19/02/2013

Although there are many colour LCDs on the market, I’ve chosen a relatively simple and popular model to examine in this tutorial – the Sparkfun Color LCD shield:

If you buy one note (shown above) that stacking headers aren’t supplied or fitted to the shield. If you get a header pack from Sparkfun or elsewhere – order PRT-10007 not PRT-11417 as the LCD shield doesn’t have the extra holes for R3 Arduino boards. However if you do have an Arduino R3 – relax … the shield works. While we’re on the subject of pins – this shield uses D3~D5 for the three buttons, and D8, 9, 11 and 13 for the LCD interface. The shield takes 5V and doesn’t require any external power for the backlight. The LCD unit is 128 x 128 pixels, with nine defined colours (red, green, blue, cyan, magenta, yellow, brown, orange, pink) as well as black and white.

So let’s get started. From a software perspective, the first thing to do is download and install the library for the LCD shield. Visit the library page here. Then download the .zip file, extract and copy the resulting folder into your ..\arduino-1.0.x\libraries folder. Then restart the Arduino IDE if it was already open.

At this point let’s check the shield is working before moving forward. Fit it to your Arduino – making sure the shield doesn’t make contact with the USB socket**. Then open the Arduino IDE and upload the TestPattern sketch found in the Examples folder. You should be presented with a nice test pattern as such:

It’s difficult to photograph the LCD – (some of them have very bright backlights), so the image may not be a true reflection of reality. Nevertheless this shield is easy to use and we will prove this in the following examples.

At the start of every sketch, you will need the following lines:

as well as the following in void setup():

With regards to lcd.init(), try it first without a parameter. If the screen doesn’t work, try PHILIPS or EPSON instead. There are two versions of the LCD shield floating about each with a different controller chip. The contrast parameter is subjective, however 63 looks good – but test for yourself. Now let’s move on to examine each function with a small example, then use the LCD shield in more complex applications.

The LCD can display 8 rows of 16 characters of text. The function to display text is:

where x and y are the coordinates of the top left pixel of the first character in the string. Another necessary function is:

Which clears the screen and sets the background colour to the parameter colour.  Please note – when referring to the X- and Y-axis in this article, they are relative to the LCD in the position shown below. Now for an example – to recreate the following display:

… use the following sketch:

In example 28.1 we used the function lcd.clear(), which unsurprisingly cleared the screen and set the background a certain colour. Let’s have a look at the various background colours in the following example. The lcd.clear()  function is helpful as it can set the entire screen area to a particular colour. As mentioned earlier, there are the predefined colours red, green, blue, cyan, magenta, yellow, brown, orange, pink, as well as black and white. Here they are in the following example:

And now to see it in action. The colours are more livid in real life, unfortunately the camera does not capture them so well.

Now that we have had some experience with the LCD library’s functions, we can move on to drawing some graphical objects. Recall that the screen has a resolution of 128 by 128 pixels. We have four functions to make use of this LCD real estate, so let’s see how they work. The first is:

This functions places a pixel (one LCD dot) at location x, y with the colour of colour.

Note – in this (and all the functions that have a colour parameter) you can substitute the colour (e.g. BLACK) for a 12-bit RGB value representing the colour required. 

Next is:

Which draws a line of colour COLOUR, from position x0, y0 to x1, y1. Our next function is:

This function draws an oblong or square of colour COLOUR with the top-left point at x0, y0 and the bottom right at x1, y1. Fill is set to 0 for an outline, and 1 for a filled oblong. It would be convenient for drawing bar graphs for data representation. And finally, we can also create circles, using:

X and Y is the location for the centre of the circle, radius and COLOUR are self-explanatory. We will now use these graphical functions in the following demonstration sketch:

You can see Example 28.3  in the following video. (There’s a section in  the video showing semi-circles – however this isn’t possible with the new Arduino v1+ library).  For photographic reasons, I will stick with white on black for the colours.

So now you have an explanation of the functions to drive the screen – and only your imagination is holding you back.  ** Get an Eleven board – it has a microUSB socket so you don’t run the risk of rubbing against shields. For another example of the colour LCD shield in use, check out my version of “Tic-tac-toe“.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, 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, education, LCD, LCD-09363, lesson, microcontrollers, tutorialComments (3)

Kit Review – Sparkfun “Simon Game”

Hello everyone

Time for a fun kit review. Aren’t all kit reviews fun? I think so, however sometimes kits can be very practical in use and perhaps not fun – unlike this little monkey. Some of you, including myself, may have childhood memories of the computer game unit from Milton-Bradley called the “Simon”. As demonstrated by the children in this video clip, Simon was a noisy game with four illuminated buttons, your task being to mimic the ever-increasing pattern of flashing buttons and matching sounds:

At first it looks easy, and it is –  however after a few repetitions the length of pattern increases and becomes more complex, forcing you to use your brain and take notice. Some would say it is useful for brain training as well.  This can only be a good thing… which brings me to this kit. The packaging is very good for a change, something you could give as a gift to a non-technical person. That is,  you could give a geek a kit in an anti-static bag, and they would understand, however a beginner may not:

boxss

The contents reveal several pleasant surprises:

partsss1

Finally – a battery-powered kit that actually includes the required power source; and not yum-cha cells, actual Duracells. Nice one Sparkfun. (If you haven’t seen that type of Duracell before, they are “trade-only” versions, generally used to deter theft). The other surprise was the inclusion of an ATmega328-PU microcontroller …

mcuss

… the exact same model as the Arduino Uno and compatible boards. Simon was starting to become more interesting every minute. But more about that later. The final object of interest is a real, live, instruction book. (You can download a copy from here). At this point you can tell this kit is made for beginners (of all ages). There is also a surface-mount component version, which people tell me is great for learning SMD work. Not for me! Good packaging, simple instructions, and a PCB that is solid and well marked out:

pcbrearss

Again, some more interesting things – what looks to be holes that would match up to an FTDI cable, in-circuit programming interface as well as some pinouts for the ATmega328.

[Update – if you’re the hacking type, it would pay to mount the IC in a socket, just in case]

However I will move forward and start the soldering. This was quite simple, just follow the guide and all is well. The instructions make a good note when a component is polarised or needs to be inserted in a certain way, very helpful for the beginner:

bottom-solderedss

and the other side was equally as simple:

top-solderedss

On this side you also need to get those AA cell clips installed. The push into their respective holes on the PCB easily, however they can be a trap to solder. Consider the following photo of one of the clips:

batt-clipss

Although the large hole in the PCB is necessary, it has left quite a gap around the wide pin. The inexperienced may end up melting lots of solder and watching it fall through to the other side; to prevent this, place the tip of your soldering iron under the acute side of the pin, and apply solder on the other side. This will force the solder to melt back onto the exposed ring on the PCB and make a good connection, instead of allowing gravity to take over the situation.

After the soldering was finished, the next task is to place the rubber button-mould over the LEDs, and then the black plastic bezel on top. The included screws go through each corner of the bezel, through the white moulding and PCB, and finally break through to the other side – where you can attach the stand-offs. Which leaves us with the final product:

finishedss1

After inserting the AA cells into their new homes, the power was turned on and the unit blinks the LEDs in a sequence until you press a button to start the game. However at this point one of the LEDs did not come on at at all. A quick check with the meter showed it was being fed almost 2.8 volts, but alas – no blinkiness. After a quick desolder/resolder job a green LED from my stock made a replacement. This would have been the only downfall for a beginner, not everyone has boxes of electronics components laying about – nor the high-intensity versions used in this kit.

However life goes on, and Simon still works just as the originals did all those years ago. Here is an example of him in action:


This is something I will need some practice on. Furthermore, the ability to control the sounds is a bonus as well; however if this Simon is aimed for small children, one could be tempted to not install the piezo transducer at all (mini speaker)! So at this stage we have an easy-to-assemble kit that is colourful, noisy and fun – a good start to help introduce another person to our fascinating world of electronics.

But wait – there’s more! Now it is time to revisit those programming holes and see what other secondary uses we can find for Simon. Seeing one of the LEDs isn’t the brightest, I will keep this one for myself, and experiment further. Therefore, the next thing to do to is solder in some header pins to allow connection to an FTDI cable:

simonftdiss

This cable converts the USB interface down to serial line levels suitable for our Simon, in the same way as the FTDI chip does for the Arduino boards (except the Uno). At this point please note you’re on your own, so if you fritz your Simon don’t take it out on me! With hindsight it would be a good idea to use an IC socket for the microcontroller.

Looking at the schematic, we can determine the pins for the LEDs, buttons and so on. The included ATmega328 has the serial bootloader for Arduino programming, so we can have a lot of easily-generated fun with it. However, note that the board does not have an external crystal or oscillator, so timing may not be as accurate as expected.

Disclaimer  – this worked for me, however your experience may vary. Alter your Simon at your own risk!

Anyhow, to use with the Arduino environment, insert the AA cells, plug in your FTDI cable, and select the board type in the environment:

arduinosetupss

Select the second option Arduino Duemilanove or Nano w/ ATmega328. Now you can upload sketches as you would a normal board. The setup functions for the LEDs are:

and for the buttons:

So armed with that knowledge you could create some  custom interactivity with your Simon hardware. If you are unsure about Arduino programming, there is a small tutorial over here that you will find helpful.

Update – New post from Sparkfun about modding your Simon. High resolution images are available on flickr. You can purchase the kit directly from Sparkfun and their resellers. 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 kit was purchased by myself personally and reviewed without notifying the manufacturer or retailer]

Posted in arduino, games, kit review, KIT-10547, KIT-10935, learning electronics, microcontrollers, simonComments (2)


Subscribe via email

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

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

Use of our content…

%d bloggers like this: