Tag Archive | "project"

Project – Simple RFID access system

In this tutorial you can make an RFID access system. It’s very simple and can be used with a wide variety of end-uses.

Updated 18/03/2013

The purpose of this project is to prototype a basic RFID access system. Although it is not that complicated, this article is my response to a kit reviewed in the Australian “Silicon Chip” (November 2010) electronics magazine. Their article describes the kit in detail – operation, schematic, use and installation. However the code for the microcontroller (PIC16F628A)  is not published due to the kit manufacturer holding copyright over the design.

This is a shame, as many organisations have been quite successful selling open-source kits. So instead of moaning about it, I have created my own design that matches the operation of the original, instead using the ATmega328 MCU with Arduino bootloader. Consider this a basic framework that you can modify for your own access system, or the start of something more involved.


There are pros and cons with the original vs. my version. The biggest pro is that you can buy the whole kit for around Au$40 including a nice PCB, solder it together, and it works. However if you want to do it yourself, you can modify it to no end, and have some fun learning and experimenting along the way. So let’s go!

The feature requirements are few. The system must be able to learn and remember up to eight RFID access tags/cards, etc – which must be able to be altered by a non-technical user. Upon reading a card, the system will activate a relay for a period of time (say 1 second) to allow operation of a door strike or electric lock. Finally, the RFID tag serial numbers are to be stored in an EEPROM in case of a power outage. When a tag is read, a matching LED (1~8) will show which tag was read. There are also two LEDs, called “Go” and “Stop” which show the activation status. The original kit has some more LEDs, which I have made superfluous by blinking existing LEDs.

This is a simple thing to make, and the transition from a solderless breadboard to strip board will be easy for those who decide to make a permanent example. But for now, you can follow with the prototype. First is the parts list:

  • Atmel ATmega328 with Arduino bootloader;
  • 16 MHz resonator (X1 in schematic);
  • ten LEDs of your choice;
  • two normally-open push buttons;
  • two 560 ohm resistors (all resistors 1/4 watt);
  • one 1k ohm resistor;
  • three 10k ohm resistors;
  • one BC548 transistor;
  • three 0.01 uF monolithic capacitors;
  • one 100 uF electrolytic capacitor;
  • one 1N4004 diode;
  • Microchip 24LC256 EEPROM;
  • 125 kHZ RFID module;
  • 125 kHz RFID tags/cards;
  • connecting wire;
  • large solderless breadboard;
  • LM7805 power regulator;
  • relay of your choice with 5V coil (example).

When selecting a relay, make sure it can handle the required load current and voltage – and that the coil current is less than 100mA.

If attempting to switch mains voltage/current – contact a licensed electrician. Your life is worth more than the money saved by not consulting an expert.

And here is the schematic (large version):


Here is the prototype on the solderless breadboard. For demonstration purposes an LED has been substituted for the transistor/relay section of the circuit, the power regulator circuitry has not been shown, and there are superfluous 4.7k resistors on the I2C bus. To program the software (Arduino sketch) the easiest way is by inserting the target IC into an Arduino-compatible board, or via a 5V FTDI cable and a basic circuit as described here.


The Arduino sketch is also quite simple. The main loop calls the procedure readTags() to process any RFID tag read attempts, and then monitors button A – if pressed, the function learnTags() is called to allow memorisation of new RFID tags. Each tag serial number consists of 14 decimal numbers, and these are stored in the EEPROM sequentially. That is, the first tag’s serial number occupies memory positions 0~13, the second tag’s serial number occupies memory position 14~28, and so on. Two functions are used to read and write tag serial numbers to the EEPROM – readEEPROMtag() and writeEEPROMtag().

The EEPROM is controlled via the I2C bus. For a tutorial about Arduino, I2C bus and the EEPROM please read this article. For a tutorial about Arduino and RFID, please read this article. The rest of the sketch is pretty self-explanatory. Just follow it along and you can see how it works. You can download the sketch from hereAnd finally, a quick video demonstration:

So there you have it. I hope you enjoyed reading about this small project and perhaps gained some use for it of your own or sparked some other ideas in your imagination that you can turn into reality.

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 hardware hacking, learning electronics, microcontrollers, projects, RDM630, RDM6300, rfidComments (12)

Tutorial: Arduino and GSM Cellular – Part Two

Continue to learn about connecting your Arduino to the cellular network with the SM5100 GSM module shield. This is chapter twenty-seven 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 02/03/2013

Assumed understanding for this article is found in part one. If you have not already done so, please read and understand it. In this instalment we continue with bare projects which you can use as a framework for your own creations.

Reach out and control something

First we will discuss how to make something happen by a simple telephone call. And the best thing is that we don’t need the the GSM module to answer the telephone call (thereby saving money) – just let the module ring a few times. How is this possible? Very easily. Recall example 26.1 – we monitored the activity of the GSM module by using our terminal software. In this case what we need to do is have our Arduino examine the text coming in from the serial output of the GSM module, and look for a particular string of characters.

When we telephone the GSM module from another number, the module returns the text as shown in the image below:


We want to look for the text “RING”, as (obviously) this means that the GSM shield has recognised the ring signal from the exchange. Therefore need our Arduino to count the number of rings for the particular telephone call being made to the module. (Memories – Many years ago we would use public telephones to send messages to each other. For example, after arriving at a foreign destination we would call home and let the phone ring five times then hang up – which meant we had arrived safely). Finally, once the GSM shield has received a set number of rings, we want the Arduino to do something.

From a software perspective, we need to examine each character as it is returned from the GSM shield. Once an “R” is received, we examine the next character. If it is an “I”, we examine the next character. If it is an “N”, we examine the next character. If it is a “G”, we know an inbound call is being attempted, and one ring has occurred. We can set the number of rings to wait until out desired function is called. In the following example, when the shield is called, it will call the function doSomething() after three rings.

The function doSomething() controls two LEDs, one red, one green. Every time the GSM module is called for 3 rings, the Arduino alternately turns on or off the LEDs. Using this sketch as an example, you now have the ability to turn basically anything on or off, or call your own particular function. Another example would be to return some type of data, for example you could dial in and have the Arduino send you a text message containing temperature data.

And now for a quick video demonstration. The first call is made, and the LEDs go from red (off) to green (on). A second call is made, and the LEDs go from green (on) to red (off). Although this may seem like an over-simplified example, with your existing Ardiuno knowledge you now have the ability to run any function by calling your GSM shield.

Control Digital I/O via SMS

Now although turning one thing on or off is convenient, how can we send more control information to our GSM module? For example, control four or more digital outputs at once? These sorts of commands can be achieved by the reception and analysis of text messages.

Doing so is similar to the method we used in example 27.1. Once again, we will analyse the characters being sent from the GSM module via its serial out. However, there are two AT commands we need to send to the GSM module before we can receive SMSs, and one afterwards. The first one you already know:

Which sets the SMS mode to text. The second command is:

This command tells the GSM module to immediately send any new SMS data to the serial out. An example of this is shown in the terminal capture below:


Two text messages have been received since the module was turned on. You can see how the data is laid out. The blacked out number is the sender of the SMS. The number +61418706700 is the number for my carrier’s SMSC (short message service centre). Then we have the date and time. The next line is the contents of the text message – what we need to examine in our sketch.

The second text message in the example above is how we will structure our control SMS. Our sketch will wait for a # to come from the serial line, then consider the values after a, b, c and d – 0 for off, 1 for on. Finally, we need to send one more command to the GSM module after we have interpreted our SMS:

This deletes all the text messages from the SIM card. As there is a finite amount of storage space on the SIM, it is prudent to delete the incoming message after we have followed the instructions within. But now for our example. We will control four digital outputs, D9~12. For the sake of the exercise we are controlling an LED on each digital output, however you could do anything you like. Although the sketch may seem long and complex, it is not – just follow it through and you will see what is happening:

And now for a video demonstration:

So there you have it – controlling your Arduino digital outputs via a normal telephone or SMS. Now it is up to you and your imagination to find something to control, sensor data to return, or get up to other shenanigans.

If you enjoyed this article, you may find this of interest – controlling AC power outlets via SMS.


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, CEL-00675, CEL-09607, cellphone hacking, cellular, GSM, hardware hacking, lesson, microcontrollers, SM5100, SMS, tutorial

Kit Review – MDC Bare-bones Board Kit (Arduino-compatible)

Hello readers

Today we continue to examine Arduino-compatible products by assembling an interesting kit from Modern Device Company – their “Bare Bones Board” (to be referred to as BBB). The BBB kit is an inexpensive way to take advantage of the Arduino Duemilanove-compatible platform, and also fills some gaps in the marketplace. Unlike the usual Arduino and compatible boards, the BBB does not maintain the recognisable form factor – that is, you cannot use the variety of Arduino shields. However, the BBB does have all the input and output connections, just in different positions.

So why would you use this kit? If you are looking to create a more permanent Arduino-based project that did not require a shield, and you are in a hurry – the BBB could be easily integrated into your design. Money is saved by not having the usual USB connection, so uploading your sketch is achieved using a 5V FTDI cable or using another Arduino board as the programmer.

Furthermore, the PCB is designed in a way that allows you to plug the BBB into the side of a solderless breadboard, which allows prototyping more complex Arduino-based circuits very easy. But more about that later. For now, let’s have a look at construction. An excellent set of instructions and a guide to use is available for download here.

In the spirit of saving money, the kit arrives in a plastic bag of sorts:


And upon emptying the contents, the following parts are introduced:


Regular readers would know that the inclusion of an IC socket makes me very happy. The PCB is thicker than average and has a great silk-screen which makes following instructions almost unnecessary. One of the benefits of this kit is the ability to connect as little or as many I/O or programming pins as required.

And for the pins A0~A5, 5V, GND and AREF you are provided with header pins and a socket, allowing you to choose. Or you could just solder directly into the board. These pins are available on the bottom-left of the PCB. However there was one tiny surprise included with the parts:


This is a 15uH SMD inductor, used to reduce noise on the analog/digital section. According to the instructions, this was originally required with Arduino-style boards that used the ATmega168 microcontroller – however the BBB now includes the current ATmega328 which does not require the inductor. However, it is good to get some SMD practice, so I soldered it in first:


Well it works, so that was a success. Soldering the rest of the main components was quite simple, thanks to the markings on the PCB. The key is to start with the lowest-profile (height) components (such as that pesky inductor) and work your way up to the largest. For example:


As you can see from the PCB close-up above, you can have control over many attributes of your board. Please note that the revision-E kit does include the ATmega328 microcontroller, not the older ‘168. For more permanent installations, you can solder directly into I/O pins, the power supply and so on.

Speaking of power, the included power regulator IC for use with the DC input has quite a low current rating – 250 mA (below left). For my use, this board will see duty in a breadboard, and also a 5V supply for the rest of the circuit, so more current will be required. Thankfully the PCB has the space and pin spacing for a 7805 5V 1A regulator (below right), so I installed my own 7805 instead:


Finally, to make my Arduino-breadboarding life easier I installed the sockets for the analogue I/O, the DC socket and a row of header pins for the digital I/O. Below is my finished example connected into a breadboard blinking some LEDs:


In this example, the board is being powered from the 5V that comes along the FTDI cable. If doing so yourself, don’t forget that there is a maximum of 500 mA available from a USB port. If you need more current (and have installed the 7805 voltage regulator) make use of the DC socket, and set the PCB power select jumper to EXT. For a better look at the kit in action, here is a short video clip:

As you can see from the various angles shown in the video, there are many points on the PCB to which you can use for power, ground, I/O connection and so on. As illustrated at the beginning of this article, a variety of header pins are included with the kit. And please note that the LED on the board is not wired into D13 as other Arduino-type boards have been… the BBB’s LED is just an “on” indicator.

However if you are using this type of kit, you most likely will not need to blink a solitary LED. However some people do use the D13 LED for trouble-shooting, so perhaps you will need it after all. Each to their own!

In conclusion, the BBB is another successful method of prototyping with the Arduino system. The kit was of a good quality, included everything required to get working the first time, and is quite inexpensive if you have a 5V FTDI cable or an Arduino Duemilanove/Uno or compatible board for sketch uploading.

Once again, thank you for reading this kit review, and I look forward to your comments and so on. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts, and if you have any questions – why not join our Google Group? It’s free and we’re all there to learn and help each other.

High resolution photos are available on flickr.

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

Posted in arduino, bare bones board, kit review, learning electronics, microcontrollers, modern devicesComments (4)

Kit review: Freetronics KitTen Arduino-compatible board

Hello everyone

Within this article we are going to examine another new kit available from Freetronics, a company formed to provide many interesting Arduino-based products after the publication of the book “Practical Arduino” by Jonathan Oxer and Hugh Blemings – which in itself is a good read, there are many interesting projects to make and learn from.

Today we examine their answer to “is there a kit version of the TwentyTen Arduino Duemilanove-compatible board?” – by assembling their KitTen. Some people may be wondering why one would want to build a KitTen instead of an assembled unit. Personally I could think of the following reasons:

  • It’s fun to make something and see it work;
  • You can save over Au$10;
  • There are a lot more smoothing capacitors in the KitTen design than normal boards;
  • There is a dedicated 3.3V 100 milliamp power regulator (twice the current of the usual board’s 50mA supply)  – ideal for running thirsty shields that need a native 3.3V;
  • The board is for a project that needs to use a modified version of the TwentyTen/Duemilanove;
  • You want a board with a native serial instead of USB interface;
  • All that lovely prototyping area above the microcontroller;
  • The power light and LED for D13 are always visible due to their location on the edge of the PCB;
  • You could solder in your microcontroller to avoid theft – great for school and public use (Yes, this has happened)…

And so on. Moving forward, opening the KitTen package reveals the following:


Once again with a Freetronics kit, all instructions are included in colour, as well as the circuit schematic and another sheet explaining how the KitTen will work with Arduino systems and the specifications. The PCB is solder-masked and silk-screened with a very informative layout:


The rest of the included components shipped in an anti-static bag, including labelled resistors and an IC socket for the microcontroller:


By following the included detailed instructions, everything went well. The layout on the PCB is detailed with all component values, which makes life easier. Starting with the low-profile components:


… followed by higher-profile components such as the IC socket and capacitors:


… and finally the shield sockets. Instead of trying to balance them, it is a lot quicker to place the sockets on an existing Arduino shield, turn it over, drop the KitTen on top then solder the pins in:


Then finally we are finished:


There are a couple of things to watch out for when using your KitTen. The first is to make sure you have the power-select jumper fitted correctly:


Place it on the left pins (as above) to power your KitTen from the FTDI cable; place the jumper on the right pins to power from the DC socket. You should use a power supply of between 9 to 12 volts DC at one amp. The second item to take care with is the blue power LED. The supplied model was so bright it was like staring into the sun. You may wish to test your own one and possibly replace it for a duller version, or use some fine sandpaper to reduce the brightness of the included LED. To upload sketches to your KitTen you will need a 5 volt FTDI cable. As mentioned above, this can also power your board as well.

Overall, this is an excellent kit, and considering the price of doing it yourself – good value as well. To get your hands on this product– visit Freetronics’ website, or your local reseller.

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

Higher resolution images available on flickr.

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

Posted in arduino, kit reviewComments (0)

Tutorial – Arduino Uno and SM5100B GSM Cellular

Shield is now obsolete. Contact your hardware supplier for support.

Posted in arduino, CEL-00675, CEL-09607, cellphone hacking, cellular, GSM, lesson, SMS, tronixstuff, tutorial

Kit review: Freetronics 16×2 LCD Arduino Shield

Hello everyone

This kit has now been discontinued, however Freetronics now have a great LCD+Keypad Shield.

Today we examine their latest kit, the “16×2 LCD Arduino Shield“. This is a very easy to construct, yet useful tool for those experimenting, prototyping and generally making things with their Arduino-based systems.  The purpose of the shield is to offer easy access to a 16 x 2 character LCD module, and also the use of five buttons – connected to an analog input using the resistor ladder method. The kit comes packaged very well, and includes not only detailed printed instructions in colour, but also the full circuit schematic:


It is nice to see such a high level of documentation, even though most people may not need it – there is generally someone who does. Sparkfun – get the hint. All the parts are included, and for the first time in my life the resistors were labelled as well:


So being Mr Pedantic I followed the instructions, and happily had the components in without any troubles. The next step was the Arduino shield pins – the best way to solder these is to insert into your Arduino board, drop the shield on top then solder away as such:


And finally, bolting on the LCD whilst keeping the header pins for the LCD in line. Some people may find the bolt closest to D0 interferes with the shield pin, so you can insert the bolt upside down as I have. Remember to not solder the LCD pins until you are happy it is seated in correctly:


Once you are satisfied the pins are lined up and sitting in their required position – solder them in, tighten your nuts and that’s it:


The contrast of the LCD in real life is better than shown in the photo above – photographing them is a little difficult for me. However once assembled, using the shield is quite easy. If your LCD doesn’t seem to be working after your first sketch, adjust the contrast using the potentiometer. The LCD is a standard HD44780-interface model, and wired in to use a 4-bit parallel data interface. If using these types of LCD is new to you, perhaps visit this article then return. Our shield uses the pins: A0 and D4~D9.

One uses the standard Arduino liquidCrystal library with this LCD, and the function parameters to use are as follows:

The buttons are read using analog pin A0. Use the following sketch to find the values returned by the analogRead function:

and a quick video of this in action:

Now that we know the values returned for each button, we can take advantage of them to create, for example, a type of menu system – or some sort of controller. In the second example, we have used a modified TwentyTen with a DS1307 real-time clock IC to make a digital clock. The buttons on the LCD shield are utilised to create a user-friendly menu to set the clock time.

You can download the demonstration sketch from here.

In general this is an excellent kit, and considering the price of doing it yourself – good value as well. To get your hands on this product in kit or assembled form – visit Freetronics’ website, or your local reseller.

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

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

Posted in arduino, kit review, LCDComments (6)

Kit review – Sparkfun Frequency Counter kit

Hello everyone

Today we examine a kit that is simple to construct and an interesting educational tool – the Sparkfun Frequency Counter kit. This is a revised design from a kit originally released by nuxie1 (the same people who brought us the original function generator kit). As a frequency counter, it can effectively measure within the range of 1 to a claimed 6.5 MHz. Unfortunately the update speed and perhaps accuracy is limited by the speed of the microcontroller the kit is based upon – the Atmel ATmega328. Arduino fans will recognise this as the heart of many of their projects.

Interestingly enough the kit itself is a cut-down version of an Arduino Duemilanove-standard board, without the USB and power regulation hardware. The ATmega328 has the Arduino bootloader and the software (“sketch”) is open source (as is the whole kit) and easily modifiable. This means you can tinker away with your frequency counter and also use your kit as a barebones Arduino board with LCD display. More about this later.

This becomes more obvious when looking at the PCB:


It was a little disappointing to not find any power regulator or DC socket – you need to provide your own 5V supply. However Sparkfun have been “clever” enough to include a cable with JST plug and socket to allow you to feed the frequency counter from their function generator kit. In other words, buy both. Frankly they might as well just have produced a function generator with frequency counter kit all on one PCB. Anyhow, let’s get building.

The kit comes in a nice reusable stiff red cardboard box. One could probably mount the kit in this box if they felt like it. The components included are just enough to get by. The LCD is a standard 16 x 2 character HD44780-compatible display. (More on these here). It has a black on green colour scheme. You could always substitute your own if you wanted a different colour scheme:


An IC socket is not included. You will need to install one if you intend to reprogram the microcontroller with another Arduino board.

Assembly was quick and painless. I couldn’t find any actual step-by-step instructions on the internet (Sparkfun could learn a lot from adafruit in this regard) however the component values are printed on the PCB silk-screen; furthermore no mention of LCD connection, but the main PCB can serve as a ‘backpack’ and therefore the pins line up.

To make experimenting with this kit easier I soldered in some header pins to the LCD and matching socket to the main PCB; as well as adding pins for an FTDI cable (5V) to allow reprogramming direct from the Arduino IDE:


So there are in fact two ways to reprogram the microcontroller – either pull it out and insert into another Arduino board, or do it in-place with a 5V FTDI cable. Either way should be accessible for most enthusiasts. At this point one can put the screen and LCD together and have a test run. Find a nice smooth 5V DC power source (from an existing Arduino is fine), or perhaps plug it into USB via a 5V FTDI cable – and fire it up:


Well, that’s a start. The backlight is on and someone is home. The next step is to get some sort of idea of the measurement range, and compare the accuracy of the completed kit against that of a more professional frequency counter. For this exercise you can observer the kit and my Tek CFC-250 frequency counter measuring the same function generator output:

As you can see the update speed isn’t that lively, and there are some discrepancies as the frequencies move upward into the kHz range. Perhaps this would be an example of the limitations caused by the CPU speed. Next on the to-do list was to make the suggested connection between the function generator kit and the frequency counter. This is quite simple, you can solder the included JST socket into the function generator board, and solder the wires of the lead included with the frequency counter as such:


When doing so, be sure to take notice about which PCB hole is connected to which hole, the colours of the wire don’t match the assumed description on the function generator PCB. Furthermore, the voltage applied via the WAVE pin (the frequency source) should not fall outside of 0~+5V.

As mentioned earlier, this kit is basically a minimalist Arduino board, and this gives the user some scope with regards to modification of the software/sketch. Furthermore, the kit has been released under a Creative Commons by-sa  license. So you can download the schematic, Arduino sketch and EAGLE files and create your own versions or updates. If doing so, don’t forget to attribute when necessary.

Overall, this was anther interesting and easy kit to assemble. It is ideal for beginners as there isn’t that much soldering, they end up with something relatively useful, and if you have a standard Arduino Uno or similar board you can upgrade the firmware yourself.

However as a standalone frequency counter, perhaps not the best choice. Think of this kit as an educational tool – involving soldering, Arduino programming and learning how frequency counters work. In this regard, the kit is well suited.

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.

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 arduino, kit review, KIT-10140Comments (2)

Tutorial: Using analog input for multiple buttons

Use multiple buttons with one analog input in chapter twenty-five of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe.

[Updated 14/03/2013]

The purpose of this article is demonstrate how you can read many push buttons (used for user-input) using only one analog input pin. This will allow you to save digital I/O pins for other uses such as LCD modules and so on. Hopefully you recall how we used analogRead() in chapter one, and how we used a potentiometer to control menu options in exercise 10.1. For this article, we will be looking at reading individual presses, not simultaneous (i.e. detecting multiple button presses).

To recap, an analog input pin is connected to an analog to digital (ADC) converter in our Arduino’s microcontroller. It has a ten bit resolution, and can return a numerical value between 0 and 1023 which relates to an analog voltage being read of between 0 and 5 volts DC. With the following sketch:

and in the following short video, we have demonstrated the possible values returned by measuring the voltage from the centre pin of a 10k ohm potentiometer, which is connected between 5V and GND:

As the potentiometer’s resistance decreases, the value returned by analogRead() increases. Therefore at certain resistance values, analogRead() will return certain numerical values. So, if we created a circuit with (for example) five buttons that allowed various voltages to be read by an analog pin, each voltage read would cause analogRead() to return a particular value. And thus we can read the status of a number of buttons using one analog pin. The following circuit is an example of using five buttons on one analog input, using the sketch from example 25.1:


And here it is in action:

Where is the current coming from? Using pinMode(A5, INPUT_PULLUP); turns on the internal pull-up resistor in the microcontroller, which gives us ~4.8V to use. Some of you may have notice that when the right-most button is pressed, there is a direct short between A5 and GND. When that button is depressed, the current flow is less than one milliamp due to the pull-up resistor protecting us from a short circuit. Also note that you don’t have to use A5, any analog pin is fine.

As shown in the previous video clip, the values returned by analogRead() were:

  • 1023 for nothing pressed (default state)
  • 454 for button one
  • 382 for button two
  • 291 for button three
  • 168 for button four
  • 0 for button five

So for our sketches to react to the various button presses, they need to make decisions based on the value returned by analogRead(). Keeping all the resistors at the same value gives us a pretty fair spread between values, however the values can change slightly due to the tolerance of resistors and parasitic resistance in the circuit.

So after making a prototype circuit, you should determine the values for each button, and then have your sketch look at a range of values when reading the analog pin. Doing so becomes more important if you are producing more than one of your project, as resistors of the same value from the same batch can still vary slightly. Using the circuit from example 25.2, we will use a function to read the buttons and return the button number for the sketch to act upon:

And now our video demonstration:

So now you have a useful method for receiving input via buttons without wasting many digital input pins. I hope you found this article useful or at least interesting.


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 analog, arduino, learning electronics, lesson, microcontrollers, multiple buttons, tutorialComments (9)

Tutorial: Arduino and monochrome LCDs

Please note that the tutorials are not currently compatible with Arduino IDE v1.0. Please continue to use v22 or v23 until further notice. 

This is chapter twenty-four 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.

Welcome back fellow arduidans!

The purpose of this article is to summarise a range of affordable monochrome liquid-crystal display units that are available to work with our Arduino; and to replace the section about LCDs in chapter two of this series. We will first examine some fixed-character and then graphical LCD units in this article. So let’s go!

Fixed-character LCD modules

When shopping around for LCD modules, these will usually be the the most common found in retail outlets. Their size is normally measured by the number of columns and rows of characters in the display. For example, the three LCDs below are 8×2, 16×2 and 20×4 characters in size:


Currently, most LCDs should have a backlight of some sort, however you may come across some heavily-discounted models on (for example) eBay that are not. Character, background and backlight colours can vary, for example:


Interfacing these screens with our Arduino boards is very easy, and there are several ways to do so. These interface types can include four- and eight-bit parallel, three-wire,  serial, I2C and SPI interfaces; and the LCD price is usually inversely proportional to the ease of interface (that is, parallel are usually the cheapest).

Four-bit parallel interface

This is the cheapest method of interface, and our first example for this article. Your LCD will need a certain type of controller IC called a Hitachi HD44780 or compatible such as the KS0066. From a hardware perspective, there are sixteen pins on the LCD. These are usually in one row:


… or two rows of eight:


The pin labels for our example are the following:

  1. GND
  2. 5V (careful! Some LCDs use 3.3 volts – adjust according to LCD data sheet from supplier)
  3. Contrast
  4. RS
  5. RW
  6. Enable
  7. DB0 (pins DB0~DB7 are the data lines)
  8. DB1
  9. DB2
  10. DB3
  11. DB4
  12. DB5
  13. DB6
  14. DB7
  15. backlight + (unused on non-backlit LCDs) – again, check your LCD data sheet as backlight voltages can vary.
  16. backlight GND (unused on non-backlit LCDs)

As always, check your LCD’s data sheet before wiring it up.

Some LCDs may also have the pinout details on their PCB if you are lucky, however it can be hard to decipher:

Now let’s connect our example 16×2 screen to our Arduino using the following diagram.

Our LCD runs from 5V and also has a 5V backlight – yours may differ, so check the datasheet:


(Circuit layout created using Fritzing)

Notice how we have used six digital output pins on the Arduino, plus ground and 5V. The 10k ohm potentiometer connected between LCD pins 2, 3 and 5 is used to adjust the display contrast. You can use any digital out pins on your Arduino, just remember to take note of which ones are connected to the LCD as you will need to alter a function in your sketch. If your backlight is 3.3V, you can use the 3.3V pin on the Arduino.

From a software perspective, we need to use the LiquidCrystal() library. This library should be pre-installed with the Arduino IDE. So in the start of your sketch, add the following line:

Next, you need to create a variable for our LCD module, and tell the sketch which pins are connected to which digital output pins. This is done with the following function:

The parameters in the brackets define which digital output pins connect to (in order) LCD pins: RS, enable, D4, D5, D6, and D7.

Finally, in your void setup(), add the line:

This tells the sketch the dimensions in characters (columns, rows) of our LCD module defined as the variable lcd. In the following example we will get started with out LCD by using the basic setup and functions. To save space the explanation of each function will be in the sketch itself. Please note that you do not have to use an Arduino Mega – it is used in this article as my usual Arduino boards are occupied elsewhere.

And here is a quick video of the example 24.1 sketch in action:

There are also a some special effects that we can take advantage of with out display units – in that we can actually define our own characters (up to eight per sketch). That is, control the individual dots (or pixels) that make up each character. With the our character displays, each character is made up of five columns of eight rows of pixels, as illustrated in the close-up below:


In order to create our characters, we need to define which pixels are on and which are off. This is easily done with the use of an array (array? see chapter four). For example, to create a solid block character as shown in the image above, our array would look like:

Notice how we have eight elements, each representing a row (from top to bottom), and each element has five bits – representing the pixel column for each row. The next step is to reference the custom character’s array to a reference number (0~7) using the following function within void setup():

Now when you want to display the custom character, use the following function:

where 0 is the memory position of the character to display.

To help make things easier, there is a small website that does the array element creation for you. Now let’s display a couple of custom characters to get a feel for how they work. In the following sketch there are three defined characters:

And here is a quick video of the example 24.2 sketch in action:

So there you have it – a summary of the standard parallel method of connecting an LCD to your Arduino. Now let’s look at the next type:

Three-wire LCD interface

If you cannot spare many digital output pins on your Arduino, only need basic text display and don’t want to pay for a serial or I2C LCD, this could be an option for you. A 4094 shift register IC allows use of the example HD44780 LCD with only three digital output pins from your Arduino. The hardware is connected as such:


And in real life:


From a software perspective, we need to use the LCD3Wire library, which you can download from here. To install the library, copy the folder within the .zip file to your system’s \Arduino-2x\hardware\libraries folder and restart the Arduino IDE. Then, in the start of your sketch, add the following line:

Next, you need to create a variable for our LCD module, and tell the sketch which of the 4094’s pins are connected to which digital output pins as well as define how many physical lines are in the LCD module. This is done with the following function:

Finally, in your void setup(), add the line:

The number of available LCD functions in the LCD3wire library are few – that is the current trade-off with using this method of LCD connection … you lose LCD functions but gain Arduino output pins. In the following example, we will demonstrate all of the available functions within the LCD3Wire library:

And as always, let’s see it in action. The LCD update speed is somewhat slower than using the parallel interface, this is due to the extra handling of the data by the 4094 IC:

Now for some real fun with:

Graphic LCD modules

(Un)fortunately there are many graphic LCD modules on the market. To keep things relatively simple, we will examine two – one with a parallel data interface and one with a serial data interface.

Parallel interface

Our example in this case is a 128 by 64 pixel unit with a KS0108B parallel interface:


For the more technically-minded here is the data sheet. From a hardware perspective there are twenty interface pins, and we’re going to use all of them. For breadboard use, solder in a row of header pins to save your sanity!

This particular unit runs from 5V and also has a 5V backlight. Yours may vary, so check and reduce backlight voltage if different.

You will again need a 10k ohm potentiometer to adjust the display contrast. Looking at the image above, the pin numbering runs from left to right. For our examples, please connect the LCD pins to the following Arduino Uno/Duemilanove sockets:

  1. 5V
  2. GND
  3. centre pin of 10k ohm potentiometer
  4. D8
  5. D9
  6. D10
  7. D11
  8. D4
  9. D5
  10. D6
  11. D7
  12. A0
  13. A1
  14. RST
  15. A2
  16. A3
  17. A4
  18. outer leg of potentiometer; connect other leg to GND
  19. 5V
  20. GND

A quick measurement of current shows my TwentyTen board and LCD uses 20mA with the backlight off and 160mA with it on. The display is certainly readable with the backlight off, but it looks a lot better with it on.

From a software perspective we have another library to install. By now you should be able to install a library, so download this KS0108 library and install it as usual. Once again, there are several functions that need to be called in order to activate our LCD. The first of these being:

which is placed within void setup(); The parameter sets the default pixel status. That is, with NON_INVERTED, the default display is as you would expect, pixels off unless activated; whereas INVERTED causes all pixels to be on by default, and turned off when activated. Unlike the character LCDs we don’t have to create an instance of the LCD in software, nor tell the sketch which pins to use – this is already done automatically. Also please remember that whenever coordinates are involved with the display, the X-axis is 0~127 and the Y-axis is 0~63.

There are many functions available to use with the KS0108 library, so let’s try a few of them out in this first example. Once again, we will leave the explanation in the sketch, or refer to the library’s page in the Arduino website. My creative levels are not that high, so the goal is to show you how to use the functions, then you can be creative on your own time. This example demonstrate a simpler variety of graphic display functions:

Now let’s see all of that in action:

You can also send normal characters to your KS0108 LCD. Doing so allows you to display much more information in a smaller physical size than using a character  LCD. Furthermore you can mix graphical functions with character text functions – with some careful display planning you can create quite professional installations. With a standard 5×7 pixel font, you can have eight rows of twenty-one characters each. Doing so is quite easy, we need to use another two #include statements which are detailed in the following example. You don’t need to install any more library files to use this example. Once again, function descriptions are in the sketch:

Again,  let’s see all of that in action:

If you’re looking for a very simple way of using character LCD modules, check this out.


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-00710, learning electronics, lesson, microcontrollers, tutorialComments (52)

Project – The “Kid-e-log”

With this project you can build an RFID time-clock system to keep track of employees, children and more.

Updated 18/03/2013

Recently I was listening to a friend who has three teenage children, of whom needed to arrive home before their parent. Unfortunately the parent needs to work all day and arrives home in the evening, and they lamented not being able to check when the children had arrived home.

After a few hours it occurred to me that a simple time clock would solve her problem – each child could check-in upon arriving home, and the parent could review the check-in times later on. And thus the kid-e-log was born.

From a hardware perspective, it would be quite simple. An LCD screen, RFID reader and some tags, and a real time clock IC such as a Maxim DS1307 – all running from the ubiquitous Arduino board. After some contemplation it occurred to me that smart kids might try to mess up the hardware by pulling the power, so it also uses an EEPROM to store time data which is impervious to power loss, and the kid-e-log will not have any user buttons. After initial programming for time and RFID key data, any changes will need to be effected by the programmer (i.e. me).

If RFID is new to you, review my Arduino tutorials before moving forward.

Before jumping ahead and making something, we discussed exactly what the function would be. Each child would have an RFID tag, and when it is read the hardware will save the arrival time in memory, and display it on the LCD. The time data will be reset automatically at 0400h or by reading an RFID card belonging to the parent. There will not be any buttons, and the hardware must be power-failure resistant – therefore EEPROM memory is needed for time data and a backup battery for the real-time clock.

From a hardware perspective, the requirements are quite simple:

  • An Arduino-style board of some sort (we used the Freetronics Eleven)
  • Maxim DS1307 or DS3232 real-time clock IC
  • Microchip 24LC256 EEPROM
  • Usual 16 character, 2 line LCD with HD44780-compatible interface
  • 125kHz RFID reader with serial output, and four RFID tags (don’t get the Weigand version!)
  • Two 4.7 kilo ohm resistors (for I2C bus with EEPROM)
  • Two 0.1 uF ceramic capacitors (for power smoothing on the breadboard)
  • a solderless breadboard for prototyping
  • a nine volt DC power adaptor, rated for no less than 300 milliamps
  • And for the final product, a nice enclosure. More on that later…

The DS1307 and the EEPROM are both using the I2C bus, and the RFID reader (more information) uses Arduino digital pin zero (serial input).  The LCD is pretty straight forward as well, as described in the tutorials.

Here is the schematic for the prototype hardware:


From a software (sketch) perspective, the design is easily broken up into distinct functions which makes programming quite easy. The sketch is a basic loop, which follows as such:

  • check to see if a tag is read by the RFID reader – if so, branch to the the reading function (which compares the read tag against those on file, and records the time matching the tag to the EEPROM)
  • display real time, date and check-in data on the LCD – another function
  • delay for a moment to stop the LCD flickering from fast updating
  • check if the time is 4am, and if so call a function to reset the check-in times

From each of those four main instructions, functions are called to handle various tasks. For example the displayData() funtion is used to read the DS1307 real time clock, and display the time and date on the top line of the LCD. Then it reads the contents of the EEPROM, and displays the check in time for each RFID tag – or a line if they have not checked in yet.

The data stored in the EEPROM is held in following order

  • tag 1 status (0 for not checked in, 1 for checked in)
  • tag 1 check-in hour
  • tag 1 check-in minute

and repeats for tag two and three. You will notice in the sketch that the RFID cards’ serial data are stored in individual arrays. You will need to read your RFID cards first with another sketch in order to learn their values. The rest of the sketch should be quite easy to follow, however if you have any questions please ask.

You can download the sketch from here. Next for the hardware. Here is our prototype, ready for action:


And now for a short video clip of the prototype kid-e-log in operation:

Notice how removing the power does not affect the real time nor the stored check-in data. Almost child-proof. The final task was to reassemble the prototype in order to fit into a nice enclosure. Unfortunately by this stage the person concerned had moved away, so I had no need to finish this project. However I had already purchased this nice enclosure:


It was just large enough to accept the Eleven board, and protoshield with the EEPROM and RFID reader circuitry, and the LCD module. It is custom-designed with mounts for Arduino boards and the LCD – a perfect fit. However the use of it can wait for another day. So an important note to self – even if designing things for a friend – get a deposit!

Such is life. I hope you enjoyed reading about this small project and perhaps gained some use for it of your own or sparked some other ideas in your imagination that you can turn into reality.

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, I2C, projects, rfid, time clock, tronixstuff, tutorialComments (3)

Quick Project – 20th Century Electronic Dice

In this tutorial we make electronic dice without using a microcontroller!

Updated 18/03/2013

After publishing an article which described the design of an electronic die (dice), one of my twitter followers said that they made them in the past just with a 555 timer IC and a 4017 logic IC. A fair point, as one does sometimes get carried away with microcontrollers sometimes. Just to show that I haven’t lost touch, here is a basic rendition of the die project again but without any of that fancy microcontroller jibber-jabber. I will just present the schematic and demonstration, however if you want to make one on some protoboard, doing so should be quite simple.

First off, here is the schematic. I really should learn to use Eagle or somesuch, but a pen and paper is so much quicker:


Now what is happening here? I’m glad you asked. On the left we have a 555 timer in astable mode. For more information about 555 ICs, please visit our part review. When the user presses SW1, power is applied to the 555 and it merrily sends out pulses from pin 3. To increase the speed of the pulses, decrease the values for R1 and R2.

The pulses are received into IC2, a “4017 five-stage Johnson decade counter”. [data sheet] This is still a very old yet useful IC. It has ten output pins, Q0~Q9. Every time the 4017 receives a pulse, starting from power-on or a reset, starting from Q0 it sets an output pin to high (pins default to low). We have sourced LEDs D1~D6 from the first six output pins on our 4017. So when it receives the fast pulses from the 555, it quickly blinks the LEDs in order. When the user releases SW1, the pulses stop arriving from the 555, and the 4017 stops counting – and leaves the current pin HIGH so we can read the value. And here it is in real life:


The parts list:

  • R1, R2 – 82k ohm resistors
  • R3 – 1.8k ohm resistor
  • C1, C3 – 100 nF polyester capacitors
  • C2 – 10nF polyester capacitor
  • D1~D6 – typical LEDs of your choice
  • IC1 – 555 timer IC
  • IC2 – 4017 CMOS counter IC
  • SW1 – normally-open button
  • 5 V power supply (use an LM7805 regulator if 5 V not available)

There are a few things to take note of if building this circuit. The 4017 IC is quite prone to static, so please take care. Furthermore, all unused output pins need to be connected to ground. (Yes, I missed that in the schematic for pin 9). And finally, you can only source 10mA per output pin, which explains the higher than usual value for R3.

Quick note: In the past we have discussed capacitors and their use for smoothing noise from DC current. The circuit above is a perfect example – the 4017 is quite susceptible to noise and will not count properly without C3 between 5V and GND.

Finally, in the spirit of this article, less is more. We could use another 555 in a monostable configuration to limit the running time of the astable 555 pulse-generating timer, but a human can do that with their digits. Furthermore, a reset button could be added onto the 4017, so that’s up to you. Finally, here it is in action:

So there. However you can now see the advantages of using a microcontroller. Each extra function or ‘trick’ created by a line or two of code with our new die could require an exponential amount of hardware, power consumption, board space and possibly a total redesign. However doing it ‘the old way’ is interesting and helps prototyping practice and troubleshooting.

But while we have all of these parts out, we’ll have a little more fun… let’s do it with an actual number being display, instead of a flurry of blinking LEDs. We still need the 555 timer to create our pulses, so that remains the same:


and here is the rest of the circuit:


So in this example, the 555 is sending out pulses on request via SW1. However this time, the 4518 BCD counter [data sheet] receives those pulses, counts them (from zero to nine then repeat) and converts the current value to binary-coded decimal. Next, the BCD value is sent over to the 4511 BCD to 7-segment driver IC [data sheet]. This IC converts reads the BCD and sets outputs that are suitable for driving 7-segment LED modules. These outputs are sent via 330 ohm resistors to protect the LED segments. Then finally, the digit zero to nine can be displayed on the LED unit.

With some trickery we could limit this display to the numbers 1~6, if you want to do that go for it. So in this case our ‘die’ has in fact 10 values. I’m sure there are some games that could make use of it. Anyhow, here it is in real life:


You may be wondering what happened to R3~R9. In this case I am using a DIP resistor array. This is just eight resistors in one package, which makes life easier.

The parts list:

  • R1, R2 – 82k ohm resistors
  • R3~R9 – 330 ohm resistors
  • C1, 100 nF polyester capacitor
  • C2 – 10nF polyester capacitor
  • D1 – common-cathode 7-segment LED display
  • IC1 – 555 timer IC
  • IC2 – 4518 CMOS counter IC
  • IC3 – 4511 BCD to 7-segment IC
  • SW1 – normally-open button
  • 5V power supply (use an LM7805 regulator if 5V not available)

And here it is in action:

You can now see why the Arduino and other microcontrollers have taken off in popularity. They really do lighten the load with regards to planning and hardware construction. However it is enjoyable to do things the old way sometimes, ergo this article. If you are interested in articles like this one that use digital electronics, please let me know via the Google Group and there will be more projects similar to this one, but in greater detail. One day I may even pull the finger out and make a TTL clock…

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 4017, 4511, 4518, 555, dice, learning electronics, tutorialComments (2)

Project – Let’s make Electronic Dice

In this project we make electronic dice.

Updated 18/03/2013

In this article you can learn how to make an electronic die (die is the singular of dice), using an ATmega328 with Arduino bootloader and a few inexpensive components. The reason for doing this is to introduce another object that you can build, learn from and be proud of. It is a fairly simple procedure, and at the end you will have something that is useful for a long time to come. Again this article will be a design-narrative, so please read it in full before making a die yourself.

First of all, here is a photo of my finished product.


Naturally the cosmetic design is up to you, I have used this box, LEDs and switches as they were already in my stock of parts. The die is quite a simple design – with a twist. Inside the unit is a mercury switch. This consists of a small glass tube with two wires at one end and a small amount of mercury. When the mercury rolls over the wires, they are shorted out. Just like a push button when it is pushed, for example:



We will make use of this switch to start the die “rolling” – to simulate the use of a non-electronic, under-engineered wooden die. For safety, I will be using a mercury switch that is enclosed with plastic:


Over the last few years several people have contacted me saying “don’t use mercury switches”. Fair enough, if you don’t want to either, use element-14  part number 540614.

First of all, the circuit is assembled on a breadboard using our Eleven Arduino-compatible board. There is no need to build the complete independent circuit yet, as we just want to test the aspects of the sketch, and try various LEDs out. I have some bright blue ones which match with the blue housing:


There is a function in the sketch (below) called

which is used to display the numbers 1 to 6. The following video is a demonstration of this:

The sketch is quite simple – you can download it from here. Once the behaviour of the die met my expectation, I used my ZIF-socket programming board to upload the sketch into a nice fresh ATmega328 with bootloader. One could also add a piezo buzzer for sound effects, as described in sketch. This will end up being a birthday present for a young niece, so I have omitted the sound effects.

Next,  time to rebuild the circuit on the breadboard – using the bootrom and not our Eleven. Here is the schematic:


and the resulting layout:


And it works! Things are starting to come together now. As usual I was curious about the current draw, as this helps me determine how long the battery will last. On standby it draws between 10 and 20 milliamps, and between 30 and 40 milliamps when displaying numbers.

By now you probably would like to see it work, so here is the prototype demonstration:

Now it is your turn… from a hardware perspective, we will need the following:

  • IC1 – ATmega328 with Arduino bootloader programmed with the sketch
  • IC2 – LM78L05 voltage regulator – note that with the front facing you, pins are 1-output, 2-GND, 3-input
  • D1-D7 – LEDs of your choosing
  • R1, R9: 10 kilo ohm resistors
  • R2-R8: 560 ohm resistors
  • X1 – 16 MHz resonator – centre pin to ground, outside pins to IC1 pins 9 and 10
  • small piece of protoboard
  • SW1 – on/off button
  • SW2 – mercury tilt switch
  • 9V PP3 battery and snap
  • optional – 28-pin IC socket
  • a nice case, but not too large
  • some thin heatshrink
  • some sponge or insulating foam which has a width and length slightly larger than the protoboard

The ideal housing would be one that fits in the palm of your hand. However, such miniaturisation levels are quite difficult in the home workshop. The biggest problem (literally) was the power supply. The only battery with the voltage and a decent amp-hour rating was the 9V PP3. Alkaline models are usually good for 500 to 625 mAh, and should power the die for about ten hours of continuous use. Furthermore, whilst running the prototype on the breadboard, it would function down to 6 volts, however the LEDs were a little dim – but still perfectly usable. However I managed to squeeze it all in – sans the IC socket.

So if you are like me, and soldering the IC in directly – make sure you are happy with your sketch!

Anyhow, time to start the hardware work of assembly. Using veroboard/protoboard is easy if you plan things out first.

Remember – to fail to plan is to plan to fail

So in this case, I like to get some graph paper and draw out the tracks with a highlighter, such as:


My diagram shows the tracks as they would be on the rear of the veroboard. With this, using a pencil one can mark out component placement, links, and where to cut tracks if necessary. Those long lines are great for +5V and ground. Etcetera. When you have laid out the parts, go and have a break. Return and check your work, then fire up your iron and go!

Once completed you then have an easy to follow plan to solder along with. Here is the above example after I finished soldering:


After the soldering was completed, and the board checked for any shorts or poor-quality joints – it was time to have a clean-up and clear the mess away. Now it was time to stuff the whole lot into the housing… but it would be prudent to test the circuit beforehand. So I soldered in the tilt switch, and the battery snap, connected the battery – and it worked. Notice in the image below the placement of the centre LED – I have used some heatshrink over the legs to totally insulate them, and have it at the centre of the board:


Now to focus on the enclosure. In order to keep the costs down I used a box (and almost everything else) from my existing stock. It turned out to be a little small, but with some creative squeezing everything would fit. The PCB and battery are separated by a thin layer of anti-static foam, to prevent the possibility of the sharp edges of the PCB underside scratching the label of the battery and causing a short.

The final messy task was to drill the holes for the LEDs and the power switch. The switch was easy enough, just knock a small hole in then use a tapered reamer to get the exact size:


Then to drill the holes in the lid for the LEDs to poke through. Easily done, just be sure to mark where you want the holes to be before drilling. Furthermore, you need to get the LEDs as far through the holes as possible:


Then the final step before sealing the lot up is to get the power wires soldered to the switch and the battery snap:


When you are putting everything in the box, make sure the tilt switch is tilted so that when the die is at rest, the tilt switch is laying in the off position. Otherwise the die will just merrily repeat forever until you turn it off.


And of course, an action video:

Once again I hope that this demonstration has shown how easy it is for anyone with some spare time and the knowledge from my Arduino tutorials can create something from scratch.

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, atmega328, dice, games, projects, tutorialComments (4)

Project – ZIF socket Arduino-compatible board

In this tutorial we make an Arduino-compatible board that holds the microcontroller in a ZIF socket.

Updated 18/03/2013

Today we are going to make a different type of Arduino-compatible board, one that has a ZIF (“zero insertion force”) socket. Our reason for making this is simple – now and again you may need to program more than one bootrom with a sketch, for example if you were planning to make your own electronics kits that were based on the Arduino system. Your alternative would be to use a chip puller and constantly insert and remove microcontrollers from your usual Arduino or compatible board – which is bad for the board, bad for the chips (the friction and pressure on the legs, as well as possible static build-up), and bad for your wrist.

So here is our problem – we need a board with a ZIF socket:


The Eleven board is great, but we just cannot squeeze in the socket. So instead, let’s make our own. Like any project, the first thing to do is plan the circuit and make a schematic:


You have to hand it to the Arduino team, they have made things very easy for us. As we are not using this board for day to day use, all we need is enough circuitry to enable programming. In this case, the connection between the board and the PC will be made with an FTDI cable (these offer an interface between serial and the USB port):


Furthermore, we will use the 5 V power supply from the USB port via the FTDI cable as well. Easy! So now it is time to collect the required parts:


You will notice in the photo above there is a button, originally I was going to have a reset button, but after testing it proved unnecessary. Our required parts consist of:

  • one 28-pin ZIF socket, 0.3″ width (don’t fall into the trap of ordering the wide one)
  • An Arduino bootrom for testing, etc
  • one 16 MHz ceramic resonator (easier than using a crystal and two capacitors, timing is not critical as this is only a programming board)
  • 6-pin header strip to connect the FTDI cable to the board
  • an FTDI cable (the 5v one)
  • two 0.1uF ceramic capacitors
  • one 10k ohm resistor
  • some rubber feet (to protect your desk when using the board
  • some veroboard
  • hookup wire, some solder, and the usual tools

Before soldering away, it pays to test the circuit on a breadboard. At this stage you can test the operation, program the microcontroller, and test that microcontroller in another board:


Again, you can ignore the button. For testing purposes, I uploaded the “blink” sketch to the microcontroller, then tested that unit in the Eleven. The LED blinked as expected, so all was good. I repeated the process a few times, but uploaded a different sketch every second time, and re-inserted the bootrom between every upload. After ten cycles of doing this, I was confident with the design, so transferred the lot to the permanent veroboard:


The black marks on the board are to help me navigate, for example the arrow means the 5 V rail, etc. Now for the rear end:


There are high-resolution photos in flickr if you want to follow this design exactly.

Before using the veroboard, experience has taught me that they are always dirty and solder doesn’t take too well. If possible, try and clean your veroboard first with some cleaning spray, usually an aerosol package available from most electronics retailers. Or even just a damp cloth, then dry the board afterwards with a dry cloth. Moving on…

Before testing the completed board, please double check the routing and that you have cut the correct PCB tracks. If you are unsure about some solder joints, use the continuity function or resistance function of a multimeter to check for shorts between tracks.

After the board passed those tests, I stuck on the feet – and admired the finished product:


However, it was time to repeat the testing. If I may make a general observation, try and test things as you move along, step by step. For example, with this project, don’t skip the breadboarding step. It is important to check the design works. Don’t skip checking for solder bridges, or not double-check your routing. It is always much easier to fix a mistake when it has been made, then to have to troubleshoot a ‘completed’ project.

But at the end of the day, I now have something that is useful and will save me time during kit production (still in design stage people), making a few blinky offspring,  and prevent damaging my regular boards. 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, atmega328, COM-09420, freetronics, microcontrollers, projects, PRT-09175, tutorial, zif socketComments (6)

Blinky the one-eyed clock

In this tutorial you learn how to make a blinking clock with a difference!

Updated 18/03/2013

Followers of my website would realise that I tend to make too many clocks in those tutorials. Well, I like making clocks… so here is another one. However this time I have tried to make the most simple version possible. Usually projects will have many LEDs, or perhaps an LCD, buzzers, buttons, all sorts of things. Which looks great and will impress many. But the other day I thought to myself … “how few things do you need to show the time?”

So here is my answer to that question: Blinky the one-eyed clock …


It reminds me of the giant killer orb from The Prisoner… Using a minimal Arduino bootloader system, a DS1307 real time clock IC and an RGB diffused LED … we can make a clock that blinks the time, using the colours of the LED to note different numerical values. For example, if the time is 12:45, the clock will blink red 12 times, then show blue for a second (think of this as the colon on a digital clock) then blink four times in green (for forty minutes), then blink three times in red for the individual minutes. If there is a zero, blink blue quickly. Then the clock will not display anything for around forty seconds, then repeat the process. Here he (she, it?) is blinking the time:

Setting the clock is simple. It is set to start at 12:00 upon power up. So for the first use you have to wait until about five seconds before midday or midnight, then power it up. To save cost it doesn’t use a backup lithium battery on the real-time clock IC, but you could if you really wanted to. If you would like to follow my design process narrative, please read on. If you only want the sketch and schematic, 🙁 head to the bottom of this article.

Design process narrative…

So let’s get started!

The first thing to do was test the RGB LED for brightness levels, so I just connected it to the digital output pins of my Eleven via suitable current-limiting resistors. Each LED is going to be different, so to ensure maximum brightness without causing any damage you need to calculate the appropriate resistor values. This is quite easy, the formula is: resistor (ohms) = voltage drop / LED current So if you have a 5 V supply, and LED that needs only 2 volts, and draws 20 milliamps (0.2 amps) , the calculation will be: resistor = (5-2)/0.02 = 150 ohms. To be safe I used a 180 ohm resistor. The LED was tested with this simple sketch:

It was interesting to alter the value of d, the delay variable, to get an idea for an appropriate blinking speed. Originally the plan was to have the LED in a photo frame, but it was decided to mount a ping-pong ball over the LED for a retro-style look.  Here is a short video of the result of the test:

If you are going to use a ping-pong ball, please be careful when cutting into it with a knife, initially it may require a lot of force, but once the knife cuts through it does so very quickly:


Now it was time to develop the sketch to convert time into blinks. The sketch itself is quite simple. Read the hours and minutes from the DS1307 timer IC; convert the hours to 12 hour time; then blink an LED for the number of hours, display another colour for the colon; divide the minutes by ten and blink that in another colour; then the modulus of minutes and ten to find the individual minutes, and blink those out. Here is the first sketch I came up with. Finally, the code was tested using the Eleven board and my DS1307 real time clock shield. It is best to use existing hardware while testing, before committing to purchasing new hardware and so on. So here it is on the breadboard:


And telling the time! In this example, the time is 3:45…

But perhaps that was a little bland. By using analogWrite() we can control the brightness of the LED segments. So now there are two more functions, whiteGlow() and blueGlow(); whose purpose is to make the display “glow” by increasing then decreasing the brightness. And scale back the amount of blinking, to increase battery life and make blinky less obvious. So now the display will glow white to announce the forthcoming display of time, wait a second, blink the time (with a blue glowing colon) then stay dark for ten seconds before repeating the process. Here is a quick demonstration of this display style:

Here is the sketch for the above demonstration, and the final one I will use with the hardware prototype. Once happy with the sketch, I put a fresh ATmega328 with Arduino bootloader in the board and programmed it with the blinky sketch, to be used in the final product.

Next was to build my own hardware. My last hardware unknown is the amount of current the circuit draws. Once I know this the correct voltage regulator and power supply can be decided upon. I had a fair idea it would be less than 100 milliamps, so I put a 6V battery onto supply duty via a 78L05 5V regulator (data sheet), and recorded the result:

So it varies, between 20.5 and 46 mA. As it only reaches 46 mA for a short time, we could consider the constant draw to be averaged out at 30 mA. I really want this to be able to run from a battery, but without having an external lead-acid battery lurking around, it will need a plug-pack with an output voltage greater than 7V DC. Another alternative would be to run it from a USB socket, a nice source of 5V. If doing so, there wouldn’t be a need for the 78L05 regulator. Which brings us to the  circuit diagram, which includes the power regulator:



It does not allow for programming in the circuit, so you will need to program the microcontroller on another Arduino or compatible board, then transfer it to the blinky circuit board as described above. At this stage I tested it again, but using a solderless breadboard. In doing so you can make final hardware checks, and  generally make sure everything works as it should. This is also a good stage to double-check you are happy with the display behaviour, default time and so on.


Time to solder up the circuit on some stripboard. Blank stripboard varies, but luckily I found this and a nice box to hold it in:


Stripboard does vary between retailers and so on, so you will need to work out the layout with your own board. In doing so, please double-check your work – follow the layout against the schematic and so on. Have a break, then check it again. There is nothing worse than soldering away to realise you are one strip too far over or something. My hand-eye coordination is not the best, therefore my soldering isn’t pretty, but it works:




One would say that there is a good argument for making your own PCBs… and I would start to agree with that. The LED is soldered to some short leads to give it a bit of play, and some heatshrink over the legs to keep them isolated:



And finally, to add a DC socket to feed blinky some power…



The last thing was to check the soldering once more under natural light, to check for bridges or shorts, then have a cup of tea. Upon my return I drilled out a hole in the enclosure lid for the LED, and one one the side for the DC socket, and fitted the lot together… and success! It worked 🙂

So there you have it. The journey from a daydream to a finished product… well a prototype anyway. But it works, and that is the best feeling of all. You can download the schematic from here. And here is the Arduino sketch:

I hope you enjoyed reading this post and hopefully felt inspired enough to make your 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.

Posted in arduino, clocks, ds1307, microcontrollers, projects, RGB LED, tutorialComments (18)

Welcome to t r o n i x s t u f f

Welcome to the tronixstuff website.

Posted in about

Let’s make a cheap +5V power supply

In this tutorial we make a simple 5V DC power supply from initial idea to finished product. This is not an exercise in making a flash power supply, just solving a problem with the parts at hand.

Updated 18/03/2013

When writing my Arduino tutorials, or generally experimenting with the breadboards – and more often both – I have needed 5V DC to power something, or in the case of working with two Arduinos at once, having to run USB cables all around the place just to power them. Some may say “Oh, just get another couple of wall warts/plug packs”. True, but good ones are over Au$20 here… and buying cheap ones have not been so successful in the past. However, I do have a collection of odd-voltage plug packs from old cordless phones and so on.. 12V AC, 15V DC etc.

So while at my desk I thought “How can I combine my need for 5V, my cheapness and use one of these plugpacks?”. Easy!

After perusing my stock database it turned out that all the parts were already around me to make a simple 5V supply using an LM7805 voltage regulator. It is quite versatile, can accept voltages up to 35V, and I have some in the drawer. Here is the data sheet: LM7805.pdf.

One should keep in mind the possible current draw from the device this is powering. The LM7805 is good for one amp, so if you’re going to milk it to the limit, your power supply should be good for around 1.5A.

Following this it occurred to me that it would be nice to not have to worry about the type of current from the plug pack – AC or DC. So my circuit needs a bridge rectifier. That can be made with four 1N4004 diodes. And it would be nice to have a power-on indicator that isn’t a tiny speck of light. Thankfully I bought some 20 mm red LEDs when element14 had a crazy sale. Perfect.

And finally, a nice enclosure. Or anything really, to hold it all together. A small semi-opaque jiffy box was hiding in the cupboard with some veroboard, so they will be used. How? Here is my schematic:


Oh – the resistor is 560 ohms. And here are the participants in this project:


The black stuff at the top-right is heatshrink. The next though was how to mount the board in the box – I don’t have any standoffs, but the box does have some slots to hold the board. So this tells me how much space there is to use on the board, as I will trim it down to fit the space available:


But before hacking things up with the tinsnips, it pays to see if your circuit will actually fit in the board space available. (However my circuit was quite small, so I knew it would fit). This can be done by laying out your parts on a sheet of paper that has a grid of dots at 2.54mm intervals. Next was to measure the internal dimensions of the box in order to cut the veroboard. Then out with the tinsnips and chop chop chop. When using tinsnips or a saw of some sort, try and cut a little outside of the line – as the PCB material does flex a little .This means that you may lose 2~3 mm at the edges, so make allowances for that.

Moving on, I now have the board sized for the box and can start component placement:


The parts just fit in together nicely. I will have to drill the holes for the 7805 regulator so it can fit, however it doesn’t really leave room for the 0.1uF capacitor. However it is not really necessary, the output will be ok without it. The leads from the power socket, and to the switch and output lead will feed from the bottom of the PCB:


Now for one final visual check, and then to solder in the components. After doing so, then it was time to put the link in and cut the tracks. I use a sanding bit on the drill to cut the tracks, completely removing the copper:


After cutting the tracks on the solder side, it was a good time to use the continuity function of the multimeter to check for shorts between tracks and other errors. The soldering proved to be fine, and the track cuts worked. Now it was time to position the DC socket and switch in order to wire them in, then drill their holes. The output wire is to come out of the top:


Now all there is to do is solder the connecting wires from the DC socket to the rear of the circuit board, and the output wire via the switch. At this point the unit was also tested. Naturally my eyesight had failed me and a short had appeared. However it was sorted out with the solder sucker:


Notice how I tied a knot in the output lead before it passes through the lid – this is to stop accidental damage to the board caused by someone pulling the wire out. Here is the finished product, with a nice red glow for a power-available indicator:


Hooray – finished. What else was there to do on a Tuesday night? The LED indicates power is supplied to the box, and the switch just controls the load. Not too happy about that 5.05V reading… but then again, that meter was somewhat inexpensive. Now let’s have a look at the CRO and look for any ripple from the supply:


The display was set to 50 millivolts per vertical division – and still a nice solid line. Considering the cost of the power supply, that’s not too bad. And we didn’t need the extra smoothing capacitor after all.

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, LM7805, power supply, projects, tutorialComments (9)

Let’s make an Arduino real time clock shield

[Updated 15/03/2013]

Today we are going to make a real time clock Arduino shield. Doing so will give you a simple way of adding … real time capability to your projects such as time, date, alarms and so on. We will use the inexpensive Maxim DS1307 real-time clock IC.

First of all, we need create our circuit diagram. Thankfully the Maxim DS1307 data sheet [pdf] has this basics laid out on page one. From examining a DS1307 board used in the past, the pull-up resistors used were 10k ohm metal films, so I’m sticking with that value. The crystal to use is 32.768 kHz, and thankfully Maxim have written about that as well in their application notes [pdf], even specifying which model to use. Phew!

So here is the circuit diagram we will follow:


Which gives us the following shopping list:

  • One arduino protoshield pack. I like the yellow ones from Freetronics
  • X1 – 32.768 kHz crystal – Citizen America part CFS206. You should probably order a few of these, I broke my first one very quickly…
  • IC1 – Maxim DS1307 real time clock IC
  • 8-pin IC socket
  • CR2032 3v battery
  • CR2032 PCB mount socket
  • R1~R3 – 10k ohm metal film resistors
  • C1 – 0.1 uF ceramic capacitor

And here are our parts, ready for action:


The first thing to do is create the circuit on a solderless breadboard. It is much easier to troubleshoot possible issues before soldering the circuit together. Here is the messy test:


Messy or not, it worked. You can use the following sketch to test the circuit is working. The next step is to consider the component placement and wiring for the protoshield. Please note that my board will most likely be different to yours, so please follow the schematic and not my board positioning. Try not to rush this step, and triple-check your layout against the schematic. As my protoshield has a green and red LED as well, I have wired the square-wave output to the green LED. You can never have too many blinking lights…




At this point I celebrated the union of tea and a biscuit. After returning to the desk, I checked the layout once more, and planned the solder bridges. All set – it was time to solder up. If you have the battery in the holder for some reason, you should remove it now, as they do not like getting warm. Furthermore, that crystal is very fragile, so please solder it in quickly.

And here we are – all soldering done except for the header sockets. At this point I used the continuity function of the multimeter to check the solder joints and make sure nothing was wrong with the circuit:




Final checks passed, so on with the headers. Just a side note – always make sure you have enough consumables, the right tools, etc., before you start a project. This is how much solder I had left afterwards…


Moving on … in with the battery and the DS1307 –  we’re done!



It is now time for the moment of truth – to insert the USB cable and re-run the sketch… and it worked! The blinking LED was too bright for me, so I de-soldered the wire. If you are making a shield, congratulations to you if yours worked as well. Note that if you are using this shield, you cannot use analog pins 4 and 5 – they are being used as the I2C bus.

So there we have it. Another useful shield, and proof that the Arduino system makes learning easy and fun. High resolution photos are available on 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, ds1307, education, projects, time clock, timing, tutorialComments (2)

Let’s make an Arduino LCD shield

In this short tutorial we make an Arduino LCD shield.

Updated 18/03/2013

Today we are going to make an Arduino shield with an LCD module. More often than not I have needed to use an LCD shield in one of my projects, or with the Arduino tutorials. Naturally you can buy a pre-made one, however doing your own is always fun and nice way to pass an afternoon. Before we start, let me say this: “to fail to plan is to plan to fail”.  That saying is very appropriate when it comes to making your own shields.

The first step is to gather all of the parts you will need. In this case:

  • an LCD module (backlit if possible, but I’m being cheap and using a non-backlit module) that is HD44780-compatible
  • a 10k linear trimpot, used to adjust the LCD contrast
  • a blank protoshield that matches your Arduino board
  • various header pins required to solder into the shield (they should be included with your protoshield)
  • plenty of paper to draw on

For example:


Next, test your parts to ensure everything works. So, draw a schematic so you have something to follow:


And then build the circuit on a solderless breadboard, so you can iron out all the hardware bugs before permanently soldering into the shield. If you have a backlit LCD, pins 15 and 16 are also used, 15 for backlight supply voltage (check your data sheet!) and 16 for backlight ground:


Once connected, test the shield with a simple sketch – for example the “HelloWorld” example in the Arduino IDE. Make sure you have the library initialization line:

filled with the appropriate parameters. If you’re not sure about this, visit the LCD display tutorial in my Arduino tutorials.

Now to make the transition from temporary to permanent. Place your components onto the protoshield, and get a feel for how they can sit together. Whilst doing this, take into account that you will have to solder some jumper wires between the various pads and the digital pin contacts and the 5V strip at the top row, as well as the GND strip on the bottom row. You may find that you have to solder jumper wires on the bottom of the shield – that’s fine, but you need to ensure that they won’t interfere with the surface of your Arduino board as well.

Furthermore, some protoshields have extra functions already added to the board. For example, the shield I am using has two LEDs and a switch, so I will need to consider wiring them up as well – if something is there, you shouldn’t waste the opportunity to not use them. If your shield has a solder mask on the rear, a great way to plan your wiring is to just draw them out with a whiteboard marker:



Remember to solder these wires in *before* the LCD … otherwise you will be in a whole world of pain. The LCD should be soldered in second-last, as it is the most difficult thing to desolder if you have made any mistakes. The last items to solder will be the header pins. So let’s get soldering…


After every solder joint, I pushed in the LCD module – in order to check my placement. You can never check too many times, even doing so I made a small mistake. Having a magnifying glass handy is also a great idea:


Now just to soldier on, soldering one pad at a time, then checking the joint and its relationship with where it should be on the board. Be very careful when applying solder to the pads, they can act as a “drain” and let lots of solder flow into the other side. If this happens you will spend some time trying to remove that excess solder – a solder sucker and some solder wick is useful for this.

Finally all the wires and pads were connected, and I checked the map once more. Soldering in the LCD was  the easiest part – but it is always the most difficult to remove – so triple check your work before installing the display. Now it was time to sit in the header sockets, and test fit the shield into my arduino board. This is done to make sure there is sufficient space between the wires on the bottom of our shield and the top of the arduino:


Even though you wouldn’t normally put a shield on top of this shield, I used the header sockets to allow access to all of the arduino pins just in case. Soldering the sockets was easy, I used blu-tack to hold them into place. Crude but effective.


And we’re finished. Soldering is not the best of my skills, so I checked continuity between the pins on the LCD and where they were supposed to go, and also electrically checked for bridges between all the soldered pins to check for shorts. A multimeter with a continuity buzzer makes this easy. Naturally I had a short between LCD pin 14 and 13, but some solder wick helped me fix that. So electrically it was correct… time to see if it actually worked! At this point it is a good idea to clear up the workspace, switch off the soldering iron, put it somewhere safe to cool down, then wash your hands thoroughly. Here are some photos of the finished product on my arduino board:




As we’re using a Freetronics protoshield with onboard LEDs, the only thing to do was alter the demonstration sketch to take account for the pin placements, and insert some code to blink the LEDs.

I never need an excuse to make a video clip, so here is the result:

So there you have it. With a little planning and care, you too can make your own Arduino shield. An LCD shield would be useful for everyone, as they are great for displaying data and requesting input, yet quite fiddly to use with a solderless breadboard. High resolution photos are available on 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, education, HD44780, LCD, projects, shield, tutorialComments (0)

bbboost chapter five – the power supply module

[3 July 2010 – this project has been retired, but the posts left for reference]

Greeting again to followers of the bbboost journey. It has been a month since the last instalment, however the 20V DC plug pack took a long time to arrive from the land of China. Nevertheless, the project is moving forward. For my new readers, the bbboost is a power supply that can be assembled by a beginner, and can offer a smooth variable DC output voltage of between ~1.8 and ~20 volts – perfect for experimenting, breadboard, and generally saving money by not buying batteries. You can just make a PCB version, or mount it in an enclosure like a professional desktop unit. No mains voltage wiring is required, so it will fine for the younger enthusiasts. Follow the project from here.

This time I have breadboarded the power supply module, using the circuit described in chapter two.  Let’s have a bit of a look:



These trimpots were ok, but it would be preferable to use the fully enclosed dustproof versions. Will order some and try ’em out.


One trimpot (the blue and white one) is 5k ohm, – to adjust between the full range, so this is the ‘coarse’ adjuster; the other trimpot is only 500 ohms and changes the voltage selected by the coarse pot by around +/- 1.2 volts. The purpose of having two controls is to make it very easy to select your required voltage down to one-hundredth of a volt. The following video clip is a rough example of this type of adjustment in action:

This power supply will also be designed for installation into a nice enclosure, so in that case one would use normal-sized potentiometers for the coarse and fine voltage adjustment.

Posted in bbboost, projects, test equipmentComments (0)

bbboost chapter four – the digital ammeter

[3 July 2010 – this project has been retired, but the posts left for reference]

Greeting again to followers of the bbboost journey. Finally the required parts arrived today so now the project can move forward. (Living in a country of 22 million people, you would think 5W resistors would be easy to come by. Think again). If this is your first brush with the bbboost project, please visit here to see what it is all about!

So today we are going to modify the voltmeter module to convert it to an ammeter (current meter) and therefore a very useful thing to have on a desktop power supply. By having an ammeter, once  your project or prototype is running you can use the current readout to determine the power supply or battery requirements for your project, or dance dangerously close to the limits of the circuitry. Careful!

However converting the voltmeter is a simple process. Using Ohm’s law, we know that current = voltage over resistance. So our problem requires us to determine the current. If we measure the voltage potential across something of a known resistance (say, a resistor), and divide the voltage by the resistance, we have the current flowing through the resistor.

I = current in Amps; V = Volts; R = resistance in Ohms.

So for example, if we have the current of our supply circuit running through a 1 ohm (5 watt – as the wattage will increase at full load) resistor, and the voltage potential across the resistor is 0.0084 volts (8.4 millivolts), the current will be 8.4 milliamps (or 0.0084 A).

Now that we already have a voltmeter, a simple removal of the 1M ohm resistor from the terminals and replacing it with a 10k ohm resistor allows the meter to measure much smaller voltages. Therefore the maximum is will measure is 999.9 mV (which we will note as mA when being used in ammeter mode). Here is the circuit diagram for the ammeter. Note the only change from the voltmeter is below the 10 nF capacitor at the bottom-left of IC1. The supply current will be running through the 1 ohm 5 watt resistor. In the next chapters we will discuss a switching solution to flip between voltmeter and ammeter without any rewiring by the end user.


Also note the change of wiring on our breadboard, it is much neater and easier to follow. The solid wires are much more reliable than the looser ones used previously. Although they can be more difficult to route around a breadboard, they will be more reliable – especially if you move the board around a lot.


There we have it! A simple conversion has made our voltmeter an ammeter with a range of 0~999.9 milliamps (basically 1 amp). Which matches nicely with the original specification of the bbboost power supply of 1 Amp. But now for the action test: measure some current! Our test subject is an LED in series with a 10k variable resistor and a 6v battery. In the video clip (no audio) we will measure the current through the circuit at three different rates, changing the resistance to alter the current three times, then comparing the readout on the bbboost and a multimeter set to mA scale. The test current values are: 0.8 mA; 12.4~5 mA (third time lucky) and 118.5 mA (bbboost) vs. 114.8 mA (multimeter). That’s a difference of 3.7 mA – for the purpose of this project, quite negligible. There is always Fluke!

The extra parts required for this section are a 10k ohm 0.25 W resistor and a 1 ohm 5W resistor.

Well that was nicely successful – except for that pesky decimal point – we didn’t do anything about it in the change from a voltmeter to an ammeter. That, my friends, is for the next instalments.

Posted in bbboost, projectsComments (0)

bbboost chapter three – the digital voltmeter

[3 July 2010 – this project has been retired, but the posts left for reference]

Our bbboost journey continues today with the prototype voltmeter module. Once complete, the bbboost will have a digital voltmeter to accurately measure the output voltage. (And maybe… an ammeter… stay tuned). Over the last week I have been pondering and experimenting on what sort of voltmeter to have. Of course it had to be digital, but what to drive it? First there was a PICAXE microcontroller using a voltage divider and the PICAXE’s analogue to digital converter. Great… except that chip can only use integers. Next…

There seem to be many cheap digital LED voltmeter modules on eBay at the moment, but where’s the fun in that?

Around six months ago I stumbled upon an interesting IC when wasting time browsing through the Farnell website, so I ordered two of them planning to do something with them later on. And promptly forgot about them. However research for the voltmeter showed this chip as ideal – the Intersil ICL7107. An analogue to digital converter and 3.5-digit LED driver all in one. Woohoo!


Data sheet is here… ICL7107 datasheet

Furthermore, this seemed like an inexpensive solution, volumes of this IC can be had for ~$2. Good so far, but after studying the data sheet – there was a catch.

It needs positive and negative five volts DC… ah fudge. The ICL7107 data sheet suggests using a CD4009 hex buffer/converter, with some diodes and capacitors. Nope, too hard and messy. However, thanks to the internet a solution was found – the ICL7660 CMOS voltage inverter!

Check it out – ICL7660 Voltage converter

So now the theoretical solution had been found, it was time to move from thinking to doing. Originally I used the circuit diagram from the Intersil web site, however calibration was a problem due to only having a single-turn potentiometer (see parts list below). So for the real unit, a multi-turn potentiometer will be used for R7.

Just a side note… breadboarding circuits can be a joy or a pain. If you use those cheap-ass breadboards from China via eBay, you will suffer. Take my word for it.

Anyhoo, before getting the circuit together, I like to line up all measure all the components – note my trusty capacitance meter …


Then put them in order according to the parts list. This will save confusion and time later on, as you have checked all the values and ensured they are correct before installation!


Here is my lovingly-crafted schematic for the voltmeter module. Note that this could be made as a standalone voltmeter, it will measure up to 20v DC. In our finished product, the +5V will be sourced from an LM78L05 voltage regulator.


And the parts list:

  • IC1 – Intersil ICL7107CPLZ
  • IC2 – Intersil ICL7660
  • D1~D3 – 1N4148 diodes
  • LED displays – Agilent HDSP521G 2 x 7-segment green displays (common anode). You can use anything really, as long as it is common anode, and each segment is ~8mA
  • R1 – 220 ohm – all resistors 0.25W
  • R2 – 10k ohm
  • R3 – 1M ohm
  • R4 – 47k ohm
  • R5 – 15k ohm
  • R6 – 100k ohm
  • R7 – 1k ohm multiturn potentiometer/trimpot (for calibration)
  • C1 – 10nF – all capacitors must be rated for at least 25V
  • C2 – 20nF
  • C3 – 470 nF
  • C4 – 100 nF
  • C5 – 100 pF
  • C6,7 – 10 uF electrolytic

Please note that this is a work in progress and errors may have been made, or values altered at any time after publication.

And now for the finished mess:


Wow – what a mess. If you are going to use a breadboard – take care with the very low value capacitors. Try to keep the legs as short as possible to improve the meter stability. When you turn it on, the display will flick a few numbers around until settling on zero. You will need to calibrate it, so just measure a solid, reliable power source (such as the output from an LM7812 and LM7805 (12V and 5V DC) in turn. So when you are measuring the (for example) 5V output from the 7805, adjust the trimpot until the display says 5.00. Try this if you can with a few different reliable voltage sources, to check your new meter’s accuracy.

Finally, this wouldn’t be complete without one of my soundless videos. In this clip, I measure a 9v battery, then an alkaline AA cell, then the same again but with reverse polarity.

So thanks once more for reading. Please leave feedback and constructive criticism or comments at your leisure… and to keep track, subscribe using the services at the top right of this page!

Posted in bbboost, ICL7107, projects, tutorialComments (8)

bbboost chapter two – which regulator?

[3 July 2010 – this project has been retired, but the posts left for reference]

In the journey to create the bbboost, first we need to start at the core – that is, the voltate regulator itself. Searching for one that meets our specification was easier than expected, I just searched for “adjustable linear voltage regulator IC” in the Farnell website and listed the results by price. The likely candidate was the National Semiconductor LM317T. Hopefully most of you would realise that this was not a surprise, the LM317 is very popular. Limor over at adafruit industries uses a Micrel MIC2941, which is also an excellent regulator, due to the low dropout voltage, which means you can create 3.3V from 3.7v (for example).

However it is just too expensive, at $1.51 each for lots of 50. The LM317T is available individually for ~78 cents, or 58 cents in amounts greater than 100. Furthermore, the LM317 can provide up to 1.5 amps of current, greater than our intial spec for the bbboost. However to keep costs down, we will stick with the assumption of one amp, unless you choose to find a 1.5A plugpack. It also has short-circuit protection on the output, and thermal shutdown. This means if it overheats, it will turn off instead of becoming damaged. However, the maximum current available will decrease if the regulator becomes hot. Now there’s an interesting experiment!

Lots of interesting information can be found on the data sheet: LM317T data sheet

One of the good things about data sheets are the example circuits, of which we can make use of for the basis of our bbboost. So thanks to National Semiconductor, here is the hand-drawn base for our bbboost, with one difference – there will be two voltage adjustment potentiometers (variable resistors). The 5k (R1) will control the voltage, however R2 will be used as a fine adjustment control. Handy if you really need 8.45V and not 8.49V…

(Sorry for the hand-written schematic. I’m still working on using the software I have. Next time…)

We will decide on a value for R2 later on, after experimenting with the voltage display. So far, our list of materials is:

  • C1 – 0.1 uF 50V greencap capacitor
  • C2 – 1.0 uF 50V electrolytic capacitor
  • IC1 – LM317T linear voltage regulator
  • R1 – 5k potentiometer
  • R2 – very low value potentiometer
  • R3 – 240 ohm 1/2 watt resistor

C1 is used to smooth any ripples in the input voltage that can be created during the AC to DC conversion in the plug pack. C2 is used to improve the transient response (i.e. keep the output voltage nice and smooth).

So at this point we will put the project to one side – I’m waiting for the parts to arrive! Be sure to subscribe for updates (see the top-right) and explore the other posts on the blog. Bye for now!

Posted in bbboost, projectsComments (0)

breadboards and batteries… bbboost

[3 July 2010 – this project has been retired, but the posts left for reference. Not my finest work, but it may help someone]

During my life in the field of electronics study, research, and daydreaming many ideas (good, bad and dangerous) and projects have been constructed using the typical solderless breadboard that everyone has used at one stage or another. There is nothing wrong with this approach, except for the power supply situation. You could either buy an expensive desktop power supply ($40 upwards), use a fixed plugpack (if you have the right voltage) then build some power smoothing into your circuit, or even use a 7805 or similar regulator to get your +5 volts. Failing that, it’s back to batteries.


You might as well just throw money into the garbage if you keep using batteries and have AC power nearby. I have had enough of worrying about all of this and have decided to conceive a desktop power supply that meets the following criteria:

  • cheap to construct
  • safe to use (not exposed to mains voltage)
  • can accept any voltage DC plugpack and offer a variable, smooth DC output of up to 1 amp
  • can be mounted on a small PC board with spacers to save money, or enclosed in a housing for a professional look
  • have a digital output voltage meter – so that it looks cool and is convenient. No more guessing with analogue meters and dealing with parallax error
  • increases the constructor’s knowledge of electronics!

Let us call it the bbboost – the bread board booster!

So over the next month or two we will do just that. If you would like to put forward ideas, suggestions or criticisms, please do so. Otherwise, get ready to say goodbye to breadboard batteries…

Posted in bbboost, projects, test equipmentComments (2)

DIY replacement cordless phone battery

For a few years now I have been using a Uniden cordless telephone system at home. Nothing special, a base unit with three handsets. However three years have passed and the batteries on the three handsets no longer hold any charge. The local excuses for electronics stores wanted almost $33 for a new battery pack (which consisted of three nickel-metal-hydride AAA cells of 800mAh capacity and a JST connecter). Hmm… three phones need three batteries…almost $99 for three batteries. Ouch.

Upon examination the battery packs were quite simple to reproduce, and there was plenty of length from the plug connectors to reuse them.
So let’s have a look. Here’s the original pack:


Here I have used three AAA NiMH 1.2V 900mAh (greater capacity cells!) with solder tabs. Thankfully there were not wider than the original cells.


So I tape them together and do a test-fit…


… solder the tabs together, keeping mind of positive and negative terminals. Two cells need to be aligned in the same direction, so some 28AWG wire connects between the + and -, covered with some electrical tape. Some narrow heatshrink would have been better, but that’s expensive as I don’t have any at home…


And here we have the finished pack in the phone. I placed the phone handset in the charge unit and kept an eye on it for three hours, it charged perfectly and the standby time is back to around seven days.


Money saved as well as the environment. Currently you can buy a whole new set including three handsets, one base unit and two charging stations for $99, but that would generate demand for much more materials, transport and so on. By replacing the packs with the cheaper cells the lesser of two environmental evils has been chosen.

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 cordless phone, projectsComments (0)

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: