Tag Archive | "Make:"

Tutorial: Arduino and the MSGEQ7 Spectrum Analyzer

This is a tutorial on using the MSGEQ7 Spectrum Analyser with Arduino, and chapter forty-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 10/11/2014

In this article we’re going to explain how to make simple spectrum analysers with an Arduino-style board. (Analyser? Analyzer? Take your pick).

First of all, what is a spectrum analyser? Good question. Do you remember what  this is?

It’s a mixed graphic equaliser/spectrum analyser deck for a hi-fi system. The display in the middle is the spectrum analyser, and roughly-speaking it shows the strength of  different frequencies in the music being listened to – and looked pretty awesome doing it. We can recreate displays similar to this for entertainment and also as a base for creative lighting effects. By working through this tutorial you’ll have the base knowledge to recreate these yourself.

We’ll be using the MSGEQ7 “seven band graphic equaliser IC” from Mixed Signal Integration. Here’s the MSGEQ7 data sheet (.pdf).  This little IC can accept a single audio source, analyse seven frequency bands of the audio, and output a DC representation of each frequency band. This isn’t super-accurate or calibrated in any way, but it works. You can get the IC separately, for example:


and then build your own circuit around it… or like most things in the Arduino world – get a shield. In this case, a derivative of the original Bliptronics shield by Sparkfun. It’s designed to pass through stereo audio via 3.5mm audio sockets and contains two MSGEQ7s, so we can do a stereo analyser:

As usual Sparkfun have saved a few cents by not including the stackable header sockets, so you’ll need to buy and solder those in yourself. There is also space for three header pins for direct audio input (left, right and common), which are useful – so if you can add those as well.

So now you have a shield that’s ready for use. Before moving forward let’s examine how the MSGEQ7 works for us. As mentioned earlier, it analyses seven frequency bands. These are illustrated in the following graph from the data sheet:

freqresponse

It will return the strengths of the audio at seven points – 63 Hz, 160 Hz, 400 Hz, 1 kHz, 2.5 kHz, 6.25 kHz and 16 kHz – and as you can see there is some overlap between the bands. The strength is returned as a DC voltage – which we can then simply measure with the Arduino’s analogue input and create a display of some sort. At this point audio purists, Sheldonites and RF people might get a little cranky, so once again – this is more for visual indication than any sort of calibration device.

However as an 8-pin IC a different approach is required to get the different levels. The IC will sequentially give out the levels for each band on pin 3- e.g. 63 Hz then 160 Hz then 400 Hz then 1 kHz then 2.5 kHz then 6.25 kHz  then 16 kHz then back to 63 Hz and so on. To start this sequence we first reset the IC by pulsing the RESET pin HIGH then low. This tells the IC to start at the first band. Next, we set the STROBE pin to LOW, take the DC reading from pin 3 with analogue input, store the value in a variable (an array), then set the STROBE pin HIGH. We repeat the strobe-measure sequence six more times to get the rest of the data, then RESET the IC and start all over again. For the visual learners consider the diagram below from the data sheet:

strobing1

To demonstrate this process, consider the function

in the following example sketch:

If you follow through the sketch, you can see that it reads both left- and right-channel values from the two MSGEQ7s on the shield, then stores each value in the arrays left[] and right[]. These values are then sent to the serial monitor for display – for example:

If you have a function generator, connect the output to one of the channels and GND – then adjust the frequency and amplitude to see how the values change. The following video clip is a short demonstration of this – we set the generator to 1 kHz and adjust the amplitude of the signal. To make things easier to read we only measure and display the left channel:


Keep an eye on the fourth column of data – this is the analogRead() value returned by the Arduino when reading the 1khz frequency band. You can also see the affect on the other bands around 1 kHz as we increase and decrease the frequency. However that wasn’t really visually appealing – so now we’ll create a small and large graphical version.

First we’ll use an inexpensive LCD, the I2C model from akafugu reviewed previously. To save repeating myself, also review how to create custom LCD characters from here.

With the LCD with have two rows of sixteen characters. The plan is to use the top row for the levels, the left-channel’s on … the left, and the right on the right. Each character will be a little bar graph for the level. The bottom row can be for a label. We don’t have too many pixels to work with, but it’s a compact example:

lcdfullon

We have eight rows for each character, and the results from an analogueRead() fall between 0 and 1023. So that’s 1024 possible values spread over eight sections. Thus each row of pixels in each character will represent 128 “units of analogue read” or around 0.63 V if the Arduino is running from true 5 V (remember your AREF notes?). The sketch will again read the values from the MSGEQ7, feed them into two arrays – then display the required character in each band space  on the LCD.

Here’s the resulting sketch:

If you’ve been reading through my tutorials there isn’t anything new to worry about. And now for the demo, with sound –

That would look great on the side of a Walkman, however it’s a bit small. Let’s scale it up by using a Freetronics Dot Matrix Display – you may recall these from Clock One. For some background knowledge check the review here.  Don’t forget to use a suitable power supply for the DMD – 5 V at 4 A will do nicely. The DMD contains 16 rows of 32 LEDs. This gives us twice the “resolution” to display each band level if desired. The display style is subjective, so for this example we’ll use a single column of LEDs for each frequency band, with a blank column between each one.

We use a lot of line-drawing statements to display the levels, and clear the DMD after each display. With this and the previous sketches, there could be room for efficiency – however I write these with the beginner in mind. Here’s the sketch:

… and here it is in action:

Conclusion

At this point you have the knowledge to use the MSGEQ7 ICs to create some interesting spectrum analysers for entertainment and visual appeal – now you just choose the type of display enjoy the results. And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

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.

Posted in analyser, analyzer, arduino, BLIPTRONICS, com-10468, dev-10306, education, graphic, lesson, MSGEQ7, sparkfun, spectrum, tutorial

Kit review – Evil Mad Science Larson Scanner

Hello readers

Time yet again for another kit review. Today’s kit is the Larson Scanner from Evil Mad Science. What a different name for a company; their byline is “DIY and open source hardware for art, education and world domination”. Art? Yes. Education? Definitely. World domination? Possibly – you could use the blinking LEDs to hypnotise the less intelligent world leaders out there.

Anyhow, what is a Larson Scanner? Named in honour of Glen A. Larson the creator of television shows such as Battlestar Galactica and Knight Rider – as this kit recreates the left and right blinking motion used in props from those television shows. For example:

The kit itself is quite inexpensive, easy to assemble – yet can be as complex as you want it to be. More about that later, for now let’s put one together and see how it performs. There are two versions of the kit, one with 5mm clear LEDs and our review model with 10mm diffused red LEDs. The kit arrives inside a huge resealable anti-static bag, as such:

1ss

Upon opening the bag we have the following parts (there was an extra LED and resistor, thanks):

4ss

… the PCB:

3ss

… which is nicely done with a good silk-screen and solder mask. And finally:

5ss

A very handy item – a battery box with power switch. The kit is powered by 2 x AA cells (not included!). And finally, the instructions:

2ss

At this point you can see that this kit is designed for the beginner in mind. The instructions are easy to read, clear, and actually very well done. If you are looking for a kit to get someone interested in electronics and to practice their soldering, you could do a lot worse than use this kit. Construction was very easy, starting with the resistors:

6ss

followed by the capacitor and button:

7ss

then the microcontroller:

8ss

… no IC socket. For a beginners’ kit, perhaps one should have been included. Next was the battery box. Some clever thinking has seen holes in the PCB to run the wires through before soldering into the board – doing so provides a good strain relief for them:

9ss

… and finally the LEDs. Beginners may solder them in one at a time:

10ss

however it is quicker to line them up all at once than solder in one batch:

11ss

… which leaves us with the final product:

13ss

Operation is very simple – the power switch is on the battery box. The button on the PCB controls the speed of LED scrolling, and if held down switches the brightness between low and high. Now for some action video of the Larson Scanner in operation:


Well that really was fun, a nice change from the usual things around here.

But wait, there’s more… although the Larson Scanner is a good training kit, it can also function in other interesting ways. The kit is completely open-source, you can download the PCB layout file, circuit schematic and microcontroller code. Get two or more and link them together to make a really wide LED display – expansion instructions are available from here. If you solder in a 6-pin PCB header to the area marked J1 on the PCB, you can reprogram the microcontroller using an STK500-compatible programmer.

After sitting my Larson Scanner next to the computer tower for a few minutes, I had contemplated fitting it into a 5.25″ drive bay to make my own Cylon PC, however that might be a little over the top. However my PC case has some dust filters on the front, which would allow LEDs to shine through in a nicely subdued way. Mounting the Larson Scanner PCB inside the computer case will be simple, and power can be sourced from the computer power supply – 5V is available from a disk drive power lead.

If you are going to modify your PC in a similar fashion, please read my disclaimer under “boring stuff” first.

The Larson Scanner can run on 3.3V without any alteration to the supplied components. What needs to be done is to use a voltage regulator to convert the 5V down to 3.3V. My example has used a 78L33 equivalent, the TI LP2950 as it is in stock. The power comes from a drive power cable splitter as such:

splitss

You may have a spare power plug in your machine, so can tap from that. 5V is the red lead, and GND is the adjacent black lead. Don’t use yellow – it is 12V. It is then a simple matter of running 5V from the red lead to pin 1 of the regulator, GND from the Larson Scanner and PC together to pin 2, and 3.3V out from the regulator to the PCB 3.3V. Insulation is important with this kind of work, so use plenty of heatshrink:

ldo1ss

… then cover the whole lot up:

ldo2ss

Now to locate a free power plug in the machine. It has been a while since opening the machine – time for a dust clean up as well:

ldo3ss

Mounting the PCB is a temporary affair until I can find some insulated mounting  standoffs:

ldo4ss

However it was worth the effort, the following video clip shows the results in action:


So there you have it. The Larson Scanner is an ideal kit for the beginner, lover of blinking LEDs, and anyone else that wants to have some easy blinking fun. You can buy Larson Scanner kits in Australia from Little Bird Electronics, or directly from Evil Mad Science for those elsewhere.

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

High resolution images are available on flickr.

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

Posted in evil mad science, kit review, larson scanner, learning electronics, tutorialComments (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)

Kit review – ogi lumen Nixie Tube system

Hello readers

Time to finish off the month with a fascinating kit review  – the ogi lumen nixie tube system. The younger readers amongst us may be thinking “what is a nixie tube?” Here is an example of four in a row:

p1080918

If you cast your mind back to before the time of LCDs, and before LEDs… to the mid-1950s. Nixie tubes were used to display data in various forms on electrical devices, from test equipment, scales, elevator indicators, possible doomsday machines, clocks – anything that required visual output would be a candidate. Although nixie tubes are now totally out of date, as with many things there is a growing trend to use them again, for cool retro-style, nostalgia and those people who enjoy living in the past.

How nixie tubes work is quite simple, an element is within a vacuum tube full of gas, such as neon. When a high-voltage (~190 volts DC) current flows through the element, it glows. For more information, here is a great explanation. You will note that they are similar to in look but different in design to the vacuum-fluorescent displays, as used in the ice tube clock reviewed a few months previously. The tubes used in this kit are the Soviet model IN-12A:

p1080865

The IN-12A tube can display the digits zero to nine, with a nice orange glow.  For the uninitiated, sourcing and making nixie tubes can be quite difficult. Apart from procuring the tubes themselves, you need a suitable power supply and logic ICs that can handle the higher voltage to control the tubes. Thankfully Ogi Lumen have put together a system of kits to make using these nixie tubes simple and interesting. There are three components to the system, the first being the power supply:

p1080879

Note that the power supply is preassembled. This supply can generate the necessary 150 to 220 volts DC to energise our nixie tubes. Yes – up to 220 volts! For example:

p1080922

However the current required is quite small – one power supply can handle up to twenty-four IN12A nixie tubes. My example in the photograph above is drawing 110~120 milliamps from a 12V DC supply. For those of you assembling these kits, please be careful. It can be easy to physically move the kit about whilst in operation, and touching the live HV pads will hurt a lot. After bumping the HV line on the PCB, my whole left arm went into a spasm and hurt for the time it took to see my doctor. So be careful.

The second item required is the driver kit. This is a board that takes care of the shift-registers and power for two of the nixie tubes. Driver kits can be slotted together to form a row of nixie tubes. The third and final item is the nixie duo kit. This contains two IN-12A tubes, matching sockets and a PCB to muont them. This PCB then slots into the driver kit PCB. You can buy the driver and duo kit as a set for a discount.

From a hardware perspective, assembling the kits is relatively simple. There isn’t any tricky soldering or SMD to worry about, however you will need a lot of solder. The contents of the duo and driver kits are as follows:

p1080869

Before you start soldering, please download and take note of the instructional .pdf files available for the duo and driver board kits. Assembling the driver kit (on the right) is very straight forward. However – please read the instructions! An interesting part of note is the K155ИД1IC:

p1080872

This is the Russian equivalent of the 74141. This is a BCD-decimal decoder IC that can handle the high voltages required for nixie tubes. When soldering the resistors, take care with R2 – it will need to be positioned horizontally so as to not rub against the duo board:

p1080934

When it is time to assemble the duo board, you will need time and patience. At a first glance, one would imagine that the sockets drop into the PCB, and the nixie tubes will happily be seated into the sockets. This is not so, don’t solder in the sockets first! The pins on the bottom of the socket also form part of the socket for the tube legs – which can alter the positioning of the socket legs. Make sure you have the socket with pin 1 at the top of the PCB. After some trial and error, the best way to insert the tubes is to first partially place the sockets into the PCB:

p1080880

… then fully insert the tubes into their sockets. Make sure the tube is the right way up – check that the digit 3 in the tube is the right way up. Then push the whole lot into the PCB. At this point you should check to make sure the sockets are in line with each other:

p1080892

(Notice how thick the PCB is…) At which point you can solder them in, followed by the row of connector pins:

p1080896

By this stage you will need some fresh air from all that soldering. The PCB holes for the socket pins really take a lot. Now you can connect the power supply to the driver board and give the tubes a test-toast:

p1080941

All the tubes should have their elements glowing. This is a good start. The next step is to connect the appropriate microcontroller and start displaying. As noted in the instructions, the 74141 BCD-decimal ICs are controlled by standard 74HC595 shift-register ICs, so your microcontroller needs to send out a data, clock and latch line. My following examples have been created using the Ardiuno system and a compatible board.

The first example is a method of displaying integers. It uses the Nixie library which you can download here.

That was just an arbitrary demonstration to get some numbers displayed. Here is a short video clip of it in action:

Now for another, more useful example. By using a DS1307 real-time clock IC with the Arduino, we can make a nice clock that displays the time and date. For more information on using the DS1307 with Arduino, please visit this tutorial. You can download the example nixie clock .pde file from here. And finally, here is the clock in action:

The problem with these tubes is that you will never have enough. Already I have thought of a few things to make that require a lot more tubes, so in the next month or so stay tuned to tronixstuff.com as there will be more projects with these kits.

In conclusion, this was a great kit and anyone looking to use some numerical nixie tubes will do very well with the Ogi Lumen products. Furthermore the designs are released under Creative Commons by-sa-nc, and the files are available to download from the product pages. And finally, it is a lot of fun – people will generally ask you about the tubes as they may have never seen them before.

Remember, if you have any questions about these modules please contact Ogi Lumen via their website. Higher resolution images available on flickr.

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.

[Note – the kit assembled in this article was received from Ogi Lumen for review purposes]

Posted in arduino, kit review, learning electronics, nixie, ogilumenComments (11)

Quick Project – Arduino Backlit LCD shield

In this tutorial learn how to make your own backlit-LCD Arduino shield.

Updated 18/03/2013

Let’s see how simple it is to make your own Arduino LCD shield. Sure – you can just buy one, but where’s the fun in that?

Getting Started

Our LCD is a two line, sixteen character backlit LCD. It has a typical HD44780-compatible interface, which makes it very easy to use with Arduino. The other parts required are laid out along with the LCD:3

partsss

We have the LCD, a Freetronics Protoshield Basic, a button, a 0.1 uF capacitor and some header pins. We also need some solid core, thin wire to make jumpers.

Next is the plan – our schematic. Even for the smaller projects, this is a wise step. You can iron out the bugs before soldering. From experience with these backlit LCDs, there are two ways to wire them up. Either with a trimpot so you can adjust the display contrast, or without. With my example screen, the display was only clear with the trimpot turned all the way to one side, however your screen may vary.

Please note that the voltage for LCD backlights can vary, some are 5V, some are 3.3V. Check your data sheet and plan accordingly!

Consider the following schematics:

schembss1

and

If you are making this circuit without the protoshield, the 0.1 uF capacitor is for decoupling, so place it between 5V and GND. It would be wise to test your LCD using the setup on pin 3 as shown in the second schematic. Then you will have a good idea about the display brightness and contrast. This was done with the usual breadboard setup, but not before soldering the pins into the LCD:

lcdpinsss

which allowed the LCD to slot into the breadboard nicely:

breadboardss

The brightness shown in the image above is satisfactory, so I measured the resistance between each of the outside pins of the trimpot and the centre. The resulting resistance between the centre and ground was around 15 ohms, so basically nothing. So for this LCD, there will not be any adjustments – and the full schematic above will be used (with LCD pin 3 going straight to GND).

The sketch to drive this LCD is quite simple, for example this will do:

For more information about using LCD modules with your Arduino, please refer to my series of Arduino tutorials.

The next step is to consider the plan for the shield. Thankfully this is a pretty simple operation, and minimal extra components to worry about. There is a catch with regards to the LCD module itself, it has six large metal tabs that need to be avoided if the LCD is to sit flush on the shield:

tabsss

Kudos to the engineers who had the pinouts printed on the back of the LCD. Thanks!

You can see that one of the tabs has been … removed. Just carefull use a pair of pliers and bend it slowly back and forth. Metal fatigue will take care of the rest. Anyhow, back to the shield. It is a simple task of soldering in some jumper wires to connect LCD pins 4, 6, 11~14 to the Arduino digital pins 4~9:

linksss

Also during this stage the reset button and the 0.1 uF capacitor were soldered in. When fitting the capacitor, leave around 5mm of length above the board, so you can push it over to one side, this is to give the LCD enough clearance. Furthermore, the lead from the 3.3V pad to LCD 15 is curved so as to avoid another metal tab on the rear of the LCD. The underside of the shield is quite simple:

linskrearss

To ensure a good solder joint when working with these shields – it is very important to heat the ring around the hole for two seconds if you need to create a solder bridge, or heat the wire for two seconds before attempting to solder it on. Otherwise you will either get a cold joint; or become frustrated and keep adding solder, at which point it leaks through to the other side and becomes a problem to remove.

Now to solder in the LCD. If you can, try and bend the LCD pins 1, 3, 5 and 16 towards the GND line, this will help when you need to connect them later. However, please be careful, if you position the LCD incorrectly you will have to basically start all over again with a new shield. When trimming the header pins, be sure to put a finger over the end to stop the cutting flying into your face:

lcdinss

Once you have the LCD module soldered in, and the ends trimmed – the final soldering task is to bridge the pins to the necessary points. This is relatively easy, just heat up one side of the junction and coax the solder across to the required spot. Sometimes the gap will be too large, so trim up the excess legs of the capacitor into small jumpers, say 3~4 mm long. You can then solder these in between the pads quite easily:

almostss

Now – the final soldering task. Snap off some header pins, two of six-pin, and two of eight-pin. Insert them into your Arduino or compatible board as such:

pinsinss

Then place your shield on top and solder the header pins to the shield. And we’re finished… well almost. Before you use the shield, use a multimeter or continuity tester to make sure none of the pins are shorted out, and generally double-check your soldering. You don’t want any mischievous short circuits ruining your new LCD or Arduino board.

Once you are satisfied, plug in your new shield and enjoy your success!

successss

So there you are, another useful Arduino shield ready for action. I hope you enjoyed reading about this project, and hopefully some of you have made one as well. High resolution images are available from flickr.

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, HD44780, LCD, microcontrollers, tutorialComments (16)

Getting started with Arduino! – Chapter Zero

Hello world!

Updated 24/11/2012

Please join with us as we learn about electronics and the Arduino! Together through this series of tutorials I would like to share with you a journey of learning, exploration and fun with the Arduino system, and make some enjoyable, useful, interesting, useless and practical things. These posts will be published on a regular basis, on top of the other non-micro controller posts. Instead of listening to someone talking really quickly on a video, you can read and follow through at your own pace, see examples in action, learn a great deal – and be inspired to make something of your own.

So let’s get started…

There are over fifty chapters in this series, however you should start here (chapter zero). However there is a full  index of articles is to your right, or can be found here. Once you have covered the material in chapters zero to thirteen you should be able to jump into any other chapter. During the first few posts, we will refer to the book:

and also assume a basic knowledge of electronics. For support or to have your questions answered, post your enquiry in our Google Group – a friendly place for such discussions.

If you would prefer an off-line method of learning, or would like a great book on the topic – consider my book “Arduino Workshop” – it’s the best book on the market for a complete beginner to learn about Arduino.

First of all, let’s breakdown the whole system into the basic parts. From there we can build an understanding of what Arduino is all about.

Arduino is an open source physical computing platform based on a simple input/output board and a development environment that implements the Processing language (www.processing.org). Arduino can be used to develop standalone interactive objects, or be connected to software on your computer. [1]

So, we have hardware and software. Our hardware will be a personal computer that can run the Arduino IDE (integrated development environment) software; and the Arduino itself and the electronics to go with it.

Our software is the IDE – software very similar to a word-processor, but can send the Arduino program (or “sketch”) to the micro controller. These sketches are programs that are written in the processing language – which is similar to C. These are interpreted by a boot loader – software in the chip that allows it to understand your sketch. As the Arduino system is open source, anyone can purchase a blank micro controller and put the boot loader on it, or even write their own boot loader or modify the original one.

Now for the Arduino itself. But what do we mean by that? Let’s have a look…

Arduino Uno

What we have is a microcontroller installed into a circuit board with a USB interface, a DC power socket, and many input and output lines (more about them later). Plus some LEDs for status reports, and other miscellaneous components. This board is the Uno, and uses the ATMega328 micro controller.

There are also larger, smaller, older and in the future newer boards – each different by their physical size, interface type, and available sketch and data memory. A very good improvement on the Arduino boards are available from Freetronics.

The purpose of the board is to simplify to a great degree access to the micro controller, and allow you to easily interface with inputs, outputs, add power supply, connect to a PC for programming, and talk to other circuits. However the board is more for your convenience, you can actually use the programmed micro controller in your own designs without the board. 

To summarise at this point – with an Arduino you can connect various forms of input and output, and create a program to process and respond to the inputs and outputs. For example, you could create a temperature alarm – when your room temperature rises above a set amount, the Arduino could sound an alarm.

Forms of input can include: buttons, switches, movement sensors, temperature sensors, light sensors, gas sensors (!), dials that you can turn (e.g. like a volume knob), wireless data receivers, etc. Forms of output can include: lights, noise-makers, motors, pumps, other circuits, liquid-crystal displays, etc. Basically anything that can be switched on or off, or controlled by electricity, can be controlled by an Arduino.

To make things easier, you can buy or make what is called a shield. This is an interface board that sits on top of your Arduino, and has various types of circuitry you can interface with. For example, an Ethernet network connection, a joystick for games or controlling a robot, or an LCD.

So that means with the right sketch, and the right hardware interface, and maybe a shield, you can do almost anything.

Great!

Thankfully that’s about all we need to learn at the moment. Now it is time to actually do something. You are going to need three things:

  • A personal computer running Linux, MacOS or Windows with a USB port, with Internet access. Then again, if you’re reading this – you’re on the ‘net
  • a USB cable that matches your board socket
  • an Arduino or compatible board. Most boards should come with a USB cable, check before buying.
Update – 10/01/2013: I have written these tutorials in a period spanning over two years. During this time several versions of the Arduino IDE have been published. Over the next few weeks I am endeavouring to update the tutorials so that they work with the latest Arduino v1.0.1 (or newer) IDE. In the meanwhile, you can run both v23 (old) and v1.0.1 (and more) on the same machine. Any tutorial noted as updated on 24/11/2012 or later works with the new IDE. Any questions – email john at tronixstuff dot com.

And now for the initial preparation – please install your Arduino IDE software using the instructions here. If you are running Ubuntu, here is an excellent installation guide.

How did you go? Did your LED blink? Were you mesmerised by it, staring blankly at all the blinky goodness? It’s ok, you can admit it – we all were the first time.

When working through this series of tutorials, some of the files you download will end with .pde or .ino. They’re both fine, the .pde extension was used for sketches written before Arduno IDE v1.0. You can load these and work with them as normal.

At this point I hope you realised that the Arduino can be powered by your computer’s USB port. However, if you want to use your programmed Arduino away from the computer, you will need a nice regulated plugpack or another source of power.

There is some really basic things to get started, however with respect to the Arduino creators, please refer to the book Getting Started with Arduino book until the end of page 38. You should be able to get that LED to blink on your own!

Exercise 0.1

Now let’s have some more blinky fun. Do you remember Knight Rider with David Hasselhoff? The ‘hoff drove a tricked-up Trans Am with some cool lights in the bonnet, a horizontal row with each light blinking in sequence from left to right to left…

Your mission, is to simply recreate this with your Arduino, using not one but eight LEDs. Blink them in an endless loop in the sequence 1-2-3-4-5-6-7-8-7-6-5-4-3-2-1-2-3-… with a delay of one second.

You will need:

  • Your standard Arduino setup (computer, cable, Uno or compatible)
  • 8 light emitting diodes (LEDs). Anything as long as they draw less than 40mA.
  • 8 560 ohm 0.25 W resistors. They are to reduce the current to protect the LEDs
  • a breadboard and some connecting wire
  • a camera (optional) – to document your success!

Hint – make the delay a variable so you can alter it easily.

From your original flashing LED project in the book, the digital pin 13 was used. This time, you can use digital pins 2 to 9. The hardware side is easy – run a wire from each digital output pin to the anode of an LED, then put a 560 ohm resistor from the cathode back to ground. See the diagram below:

exercise0p1

And this is what the result should hopefully look like:

And of course, here it is in action:

Now it is your turn to do something – write the code! But before you do that, plan what you want to do first (some old-schoolers would call the plan an algorithm). For example, for this exercise you might write something like…

exercise 0.1 plan

set all the pins I want to use as outputs
create a variable to store the delay duration in milliseconds
start an infinite loop
turn on pin 2, wait for delay duration, turn it off
turn on pin 3, wait for delay duration, turn it off
repeat for pins 4 to 9
then do the same thing but backwards down to pin 3
end of infinite loop

So how did you go? Did it work first time? It’s ok if it didn’t, as you learn by doing and fixing your mistakes. Remember – if you have any questions, leave a comment at the bottom of this post and I will get back to you. But to save you time, here is the sketch:

So there you have it. Today you have learned how to set up a computer to program your Arduino, and written some sketches to create outputs based on your design. Although it wasn’t that much, we have to start somewhere… but great things will follow. Like chapter one! 

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.

Notes:

[1] from “Getting Started with Arduino” by Massimo Banzi (O’Reilly).

Posted in arduino, basic, book, lesson, microcontrollers, tutorialComments (15)


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: