Book – “Arduino Workshop – A Hands-On Introduction with 65 Projects”
Over the last few years I’ve been writing a few Arduino tutorials, and during this time many people have mentioned that I should write a book. And now thanks to the team from No Starch Press this recommendation has morphed into my new book – “Arduino Workshop“:
Although there are seemingly endless Arduino tutorials and articles on the Internet, Arduino Workshop offers a nicely edited and curated path for the beginner to learn from and have fun. It’s a hands-on introduction to Arduino with 65 projects – from simple LED use right through to RFID, Internet connection, working with cellular communications, and much more.
Each project is explained in detail, explaining how the hardware an Arduino code works together. The reader doesn’t need any expensive tools or workspaces, and all the parts used are available from almost any electronics retailer. Furthermore all of the projects can be finished without soldering, so it’s safe for readers of all ages.
The editing team and myself have worked hard to make the book perfect for those without any electronics or Arduino experience at all, and it makes a great gift for someone to get them started. After working through the 65 projects the reader will have gained enough knowledge and confidence to create many things – and to continue researching on their own. Or if you’ve been enjoying the results of my thousands of hours of work here at tronixstuff, you can show your appreciation by ordering a copy for yourself or as a gift
You can review the table of contents, index and download a sample chapter from the Arduino Workshop website.
Arduino Workshop is available from No Starch Press in printed or ebook (PDF, Mobi, and ePub) formats. Ebooks are also included with the printed orders so you can get started immediately.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
SMD Soldering made easier
Hooray – we’re back…
SMD (surface mount device) soldering to some people can seem scary and dangerous. And if done incorrectly, or in the wrong state of mind, and/or with the wrong equipment – it can be. Or like myself, you could be pretty bad at it. To make things easier, I’d like to point you in a few directions to find help and guidance if this technique is new to you. Furthermore, if you find any more resources, leave a comment below and we will investigate them further.
First up we have a new comic from Greg Peek and Dave Roberts from siliconfarmers.com, (written in a similar vein to the “Soldering is Easy” comic that was released in 2010) that is easy to read and makes sense. Here is the cover:
As you can see from the CC logo on the title page, the comic is in the public domain, so please print it out, email it, and generally distribute it far and wide. For more information about the authors see their website at siliconfarmers.com. I have also placed the file here at tronixstuff for you to download.
Next we have a detailed and nicely illustrated tutorial by Jon Oxer from freetronics.

Jon runs through the process of soldering with a toaster over, with great success. So head over and have a read.
For the first video tutorial we have the SMD episide of the series by David L. Jones at eevblog, well worth the time:
Next, the people from Sparky’s Widgets doing some drag soldering:
That’s all we have for now, so if you find any more that are worthwhile leave a comment below.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
Hewlett-Packard 5082-7415 LED Display from 1976
In this article we examine a five digit, seven-segment LED display from Hewlett-Packard, the 5082-7415:
According to the data sheet (HP 5082-series.pdf) and other research this was available for a period of time around 1976 and used with other 5082-series modules in other HP products. Such as the Hewlett-Packard 3x series of calculators, for example:

Using the display is very easy – kudos to the engineers at HP for making a simple design that could be reusable in many applications. The 5082-7415 is a common-cathode unit and wiring is very simple – there are the usual eight anodes for segments a~f and the decimal point, and the five cathodes.
As this module isn’t too easily replaceable, I was very conservative with the power supply – feeding just under 1.6V at 10mA to each of the anode pins. A quick test proved very promising:
Excellent – it worked! But now to get it displaying some sort of interesting way. Using the following hardware…
- Freetronics Eleven Arduino-compatible board
- Two 74HC595 shift registers
- Eight 560 ohm resistors
- Five 1k ohm resistors
- Five BC548 transistors
- A large solderless breadboard and plenty of wires
… it was connected in the same method as a four-digit display (except for the extra digit) as described in my tutorial. Don’t forget to use the data sheet (HP 5082-series.pdf). You don’t have to use Arduino – any microcontroller with the appropriate I/O can take care of this.
Here is a simple Arduino sketch that scrolls through the digits with and then without the decimal point (download):
// Arduino sketch to demonstrate HP 5082-7415 LED Display unit // John Boxall, April 2012
int clockPin=6; int latchPin=7; int dataPin=8;
// array for cathodes - sent to second shift register
byte digits[]={
B10000000, B01000000, B00100000, B00010000, B00001000, B11111000}; // use digits[6] to turn all on
// array for anodes (to display 0~0) - sent to first shift register
byte numbers[]={
B11111100, B01100000, B11011010, B11110010, B01100110, B10110110, B10111110, B11100000, B11111110, B11110110};
void setup()
{
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop()
{
int i;
for ( i=0 ; i<10; i++ )
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, digits[6]);
shiftOut(dataPin, clockPin, LSBFIRST, numbers[i]);
digitalWrite(latchPin, HIGH);
delay(250);
}
// now repeat with decimal point
for ( i=0 ; i<10; i++ )
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, digits[6]);
shiftOut(dataPin, clockPin, LSBFIRST, numbers[i]+1);
digitalWrite(latchPin, HIGH);
delay(250);
}
}
And the results:
Now for something more useful. Here is a function that sends a single digit to a position on the display with the option of turning the decimal point on or off:
void displayDigit(int value, int posit, boolean decPoint)
// displays integer value at digit position posit with decimal point on/off
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, digits[posit]);
if (decPoint==true)
{
shiftOut(dataPin, clockPin, LSBFIRST, numbers[value]+1);
}
else
{
shiftOut(dataPin, clockPin, LSBFIRST, numbers[value]);
}
digitalWrite(latchPin, HIGH);
}
So if you wanted to display the number three in the fourth digit, with the decimal point – use
displayDigit(3,3,true);
with the following result:
We make use of the displayDigit() function in our next sketch. We introduce a new function
displayInteger(number,cycles);
It accepts a long integer between zero and 99999 (number) and displays it on the module for cycles times. You can download the sketch from here.
// Arduino sketch to demonstrate HP 5082-7415 LED Display unit // Displays numbers on request // John Boxall, April 2012
int clockPin=6; int latchPin=7; int dataPin=8;
// array for cathodes - sent to second shift register
byte digits[]={
B10000000,
B01000000,
B00100000,
B00010000,
B00001000,
B11111000}; // use digits[6] to turn all on
// array for anodes (to display 0~0) - sent to first shift register
byte numbers[]={
B11111100,
B01100000,
B11011010,
B11110010,
B01100110,
B10110110,
B10111110,
B11100000,
B11111110,
B11110110};
void setup()
{
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
randomSeed(analogRead(0));
}
void clearDisplay()
// turns off all digits
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0);
shiftOut(dataPin, clockPin, LSBFIRST, 0);
digitalWrite(latchPin, HIGH);
}
void displayDigit(int value, int posit, boolean decPoint)
// displays integer value at digit position posit with decimal point on/off
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, digits[posit]);
if (decPoint==true)
{
shiftOut(dataPin, clockPin, LSBFIRST, numbers[value]+1);
}
else
{
shiftOut(dataPin, clockPin, LSBFIRST, numbers[value]);
}
digitalWrite(latchPin, HIGH);
}
void displayInteger(long number,int cycles)
// displays a number 'number' on the HP display.
{
long i,j,k,l,z;
float f;
clearDisplay();
for (z=0; z
void loop()
{
long l2;
l2=random(0,100001);
displayInteger(l2,400);
}
For demonstration purposes the sketch displays random numbers, as shown in the video below:
Update – 23/04/2012
Finally after some more hunting around I found some four-digit (possible knock-off versions of the) HP QDSP-6064 display units on eBay (item #120876219746) as shown below:
They worked very nicely and can be driven in the same method as the 5082-7415s descibed earlier. In the following video we have run the same sketches with the new displays:
In the meanwhile, I hope you found this article of interest. Thanks to the Vintage Technology Association website and the Museum of HP Calculators for background information and Freetronics for the use of the Eleven.
Project: Clock Three – A pillow clock
A pillow clock? How? Read on…
Updated 18/03/2013
Time for another instalment in my irregular series of irregular clock projects. In contrast with the minimalism of Clock Two, in this article we describe how to build a different type of clock – using the “lilypad” style of Arduino-compatible board and components designed for use in e-textiles and wearable electronics. As the LilyPad system is new territory for us, the results have been somewhat agricultural. But first we will examine how LilyPad can be implemented, and then move on to the clock itself.
The LilyPad system
By now you should have a grasp of what the whole Arduino system is all about. If not, don’t panic – see my series of tutorials available here. The LilyPad Arduino boards are small versions that are designed to be used with sewable electronics – in order to add circuitry to clothing, haberdashery items, plush toys, backpacks, etc. There are a few versions out there but for the purpose of our exercise we use the Protosnap Lilypad parts which come in one PCB unit for practice, and then can be ‘snapped out’ for individual use. Here is an example in the following video:
The main circular board in the Arduino-type board which contains an ATmega328 microcontroller, some I/O pins, a header for an FTDI-USB converter and a Li-Ion battery charger/connector. As an aside, this package is good start – as well as the main board you receive the FTDI USB converter, five white LEDs, a buzzer, vibration module, RGB LED, a switch, temperature sensor and light sensor. If you don’t want to invest fully in the LilyPad system until you are confident, there is a smaller E-Sewing kit available with some LEDs, a battery, switch, needle and thread to get started with.
Moving forward – how will the parts be connected? Using thread – conductive thread. For example:
This looks and feels like normal thread, and is used as such. However it is conductive – so it doubles as wire. However the main caveat is the resistance – conductive thread has a much higher resistance than normal hook-up wire. For example, measuring a length of around eleven centimetres has a resistance of around 11Ω:
So don’t go too long with your wire runs otherwise Ohm’s Law will come into play and reduce the available voltage. It is wise to try and minimise the distance between parts otherwise the voltage potential drop may be too much or your digital signals may have issues. Before moving on to the main project it doesn’t hurt to practice sewing a few items together to get the hang of things. For example, run a single LED from a digital output – here I was testing an LED by holding it under the threads:
Be careful with loose live threads – it’s easy to short out a circuit when they unexpectedly touch. Finally for more information about sewing LilyPad circuits, you can watch some talent from Sparkfun in this short lesson video:
And now to the Clock!
It will be assumed that the reader has a working knowledge of Arduino programming and using the DS1307 real-time clock IC. The clock will display the time using four LEDs – one for each digit of the time. Each LED will blink out a value which would normally be represented by the digit of a digital clock (similar to blinky the clock). For example, to display 1456h the following will happen:
- LED 1 blinks once
- LED 2 blinks four times
- LED 3 blinks five times
- LED 4 blinks six times
If a value of zero is required (for example midnight, or 1000h) the relevant LED will be solidly on for a short duration. The time will be set when uploading the sketch to the LilyPad, as having two or more buttons adds complexity and increases the margin for error. The only other hardware required will be the DS1307 real-time clock IC. Thankfully there is a handy little breakout board available which works nicely. Due to the sensitivity of the I2C bus, the lines from SDA and SCL to the LilyPad will be soldered. Finally for power, we’re using a lithium-ion battery that plugs into the LilyPad. You could also use a separate 3~3.3 V DC power supply and feed this into the power pins of the FTDI header on the LilyPad.
Now to start the hardware assembly. First – the RTC board to the LilyPad. The wiring is as follows:
- LilyPad + to RTC 5V
- LilyPad – to RTC GND
- LilyPad A4 to RTC SDA
- LilyPad A5 to RTC SCL
At this stage it is a good idea to test the real-time clock. Using this sketch, you can display the time data on the serial monitor as such:
Sewing it together…
Once you have the RTC running the next step is to do some actual sewing. Real men know how to sew, so if you don’t – now is the time to learn. For our example I bought a small cushion cover from Ikea. It is quite dark and strong – which reduces the contrast between the conductive thread and the material, for example:
However some people like to see the wires – so the choice of slip is up to you. Next, plan where you want to place the components. The following will be my rough layout, however the LilyPad and the battery will be sewn inside the cover:
The LilyPad LEDs have the current-limiting resistor on the board, so you can connect them directly to digital outputs. And the anode side is noted by the ‘+’:
For our example we connect one LED each to digital pins six, nine, ten and eleven. These are also PWM pins so a variety of lighting effects are available. The cathode/negative side of the LED modules are connected together and then return to the ‘-’ pad on the LilyPad. The actual process of sewing can be quite fiddly – so take your time and check your work. Always make note to not allow wires (threads) to touch unless necessary. It can help to hold the LilyPad up and let the cloth fall around it to determine the location of the LilyPad on the other side, for example:
As this was a first attempt – a few different methods of sewing the parts to the cloth were demonstrated. This becomes evident when looking on the inside of the slip:
… however the end product looked fair enough:
After sewing in each LED, you could always upload the ‘blink’ sketch and adapt it to the LEDs – a simple way to test your sewing/wiring before moving forward.
The sketch…
As usual with my clock projects the sketch is based around the boilerplate “get time from DS1307″ functions. There is also the function blinkLED which is used to control the LEDs, and the time-to-blinking conversion is done in the function displayTime. For those interested, download and examine the sketch.
The results!
Finally in the video clip below our pillow clock is telling the time – currently 1144h:
So there you have it, the third of many clocks we plan to describe in the future. Once again, this project is just a demonstration – so feel free to modify the sketch or come up with your own ideas.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
Project: Clock Two – Single digit clock
Let’s hack an Ikea lamp into a single-digit clock! How? Read on…
Updated 18/03/2013
Time for another instalment in my irregular series of clock projects. (Or should that be “Time for another instalment in the series of irregular clock projects”?) In contrast with the extreme “blinkiness” of Clock One, in this article we describe how to build this single-digit digital clock:
Once again the electronics of the clock will be based from an Arduino-compatible board with a DS1307 real-time clock IC added to the board. On top of this we add a shield with some extra circuitry and two buttons – but more on this later. The inspiration for this clock came from a product that was recently acquired at Ikea – the “Kvart” work lamp, for example:
If you are shopping for one, here are the Ikea stock details:
The goal is to place the electronics of the clock in the base, and have one single-digit LED display at the top of the neck which will blink out the digits. There will be two buttons under the base that are used to set the time. It will be powered by a 9V battery or an AC adaptor which is suitable for a typical Arduino board.
Construction
This article is a diary of my construction, and you can always use your own knowledge and initiative. It is assumed that you have a solid knowledge of the basics of the Arduino system. If not, review my series of tutorials available from here. Furthermore, feel free to modify the design to work with what you have available – I hope this article can be of some inspiration to you.
Software
It is much easier to prototype the clock and get the Arduino sketch working how you like it before breaking down the lamp and building up the clock. To do this involves some jumper wires and a solderless breadboard, for example:
Although there are four buttons on the board we only use two. They are connected to digital pins eight and nine (with 10k pull-down resistors). The LED display segments a~g are connected to Arduino digital pins 0~6 respectively. The decimal point is connected to the pulse output pin of the DS1307 – which will be set to a 1Hz output to have a nice constant blinking to show the clock is alive and well.
If you are unfamiliar with operating the DS1307 real-time clock IC please review this tutorial. Operation of the clock has been made as simple for the user as possible. To set the time, they press button A (on digital eight) while the current time is being displayed, after which point the user can select the first digit (0~2) of the time by pressing button A. Then they press button B (on digital nine) to lock it in and move to the second digit (0~9) which is again chosen with button A and selected with button B. Then they move onto the digits in the same manner.
After this process the new time is checked for validity (so the user cannot enter invalid times such as 2534h) – and is ok, the clock will blink the hyphen twice and then carry on with the new time. If the entered time is invalid, the clock reverts back to the current time. This process is demonstrated in the following video clip:
You can download the Arduino sketch from here.
Hardware
The parts required to replicate the Clock Two in this article are:
- One Arduino-compatible board with DS1307 real-time clock IC as described in this article
- One Arduino protoshield and header pins
- One common-cathode 7-segment LED display of your choosing
- Seven current-limiting resistors to reduce the output current from Arduino digital outputs going to the LED segments. In our example we use a 560 ohm resistor network to save time
- Two buttons and two 10k ohm pull-down resistors
- One meter of nine-core wire that will fit inside the neck and stand of the Kvart lamp – an external diameter of less than 6mm will be fine
- And of course – the lamp
The protoshield is used to hold the buttons, resistor network and the terminus for the wires between the LED display and the Arduino digital outputs, for example:
At this stage you will need to do some heavy deconstruction on the lamp. Cut off the mains lead at the base and remove the plastic grommet from the stand that surrounded the AC lead. Next, with some elbow grease you can twist off the lamp-shade unit from the end of the flexible neck. You could always reuse the lamp head and AC lead if wired by a licensed electrician.
Now you need to feed the multicore wire through the neck and down to the base of the lamp. You can pull it through the hole near the base, and then will need to drill a hole in the base to feed it through to the electronics as such:
Take care when feeding the cable though so you don’t nick the insulation as shown above. Leave yourself a fair bit of slack at the top which will make life easier when soldering on the LED display, for example:
The next step is to solder the wires at the top to the LED display. Make notes to help recall which wires are soldered to the pins of the display. If your soldering skills (like mine) aren’t so good, use heatshrink to cover the soldering:
Most displays will have two GND pins, so bridge them so you only need to use one wire in the multicore back to base:
At this point use the continuity function of a multimeter or a low-voltage power source to test each LED segment using the other end of the cable protruding from the base. Once you are satisfied the segments have been soldered correctly, carefully draw the cable back through the neck and base in order to reduce the slack between the display and the top of the lamp neck. Then solder the individual LED segment wires to the protoshield.
Now if you have not already done so, upload the sketch into the Arduino board – especially if you are going to permanently mount the circuitry into the base. A simple method of mounting would be using a hot glue gun, but for the purpose of demonstration we have just used blu-tac:
Although this does look a little rough, we are using existing stock which kept the cost down. If you are going to power the clock with an AC adaptor, you will also need to cut out small opening to allow the lead to protrude from the side of the base. And now for the resulting clock – our Clock Two:
So there you have it, the second of many clocks we plan to describe in the future.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
Review: Mayhew Labs “Go Between” Arduino Shield
Hello readers
In this article we examine one of those products that are really simple yet can solve some really annoying problems. It is the “Go Between” Arduino shield from Mayhew Labs. What does the GBS do? You use it to solve a common problem that some prolific Arduino users can often face – how do I use two shields that require the same pins?
Using a clever matrix of solder pads, you can change the wiring between the analogue and digital pins. For example, here is the bare shield:
Now for an example problem. You have two shields that need access to digital pins 3, 4 and 5 as also analogue pins 4 and 5. We call one shield the “top shield” which will sit above the GBS, and the second shield the “bottom” shield which will sit between the Arduino and the GBS. To solve the problem we will redirect the top shield’s D3~5 to D6~8, and A4~5 to A0~1.
To redirect a pin (for example D3 to D6), we first locate the number along the “top digital pins” horizontal of the matrix (3). Then find the destination “bottom” pin row (6). Finally, bridge that pad on the matrix with solder. Our D3 to D6 conversion is shown with the green dot in the following:
Now for the rest, diverting D4 and D5 to D7 and D8 respectively, as well as analogue pins 4 and 5 to 0 and 1:
The next task is to connect the rest of the non-redirected pins. For example, D13 to D13. We do this by again bridging the matching pads:
Finally the sketch needs to be rewritten to understand that the top shield now uses D6~8 and A0~1. And we’re done!
Try not to use too much solder, as you could accidentally bridge more pads than necessary. And you can always use some solder wick to remove the solder and reuse the shield again (and again…). Now the genius of the shield becomes more apparent.
It is a small problem, but one nonetheless. Hopefully this is rectified in the next build run. Otherwise the “Go Between” Shield is a solution to a problem you may have one day, so perhaps keep one tucked away for “just in case”.
While we’re on the subject of Arduino shield pinouts, don’t forget to check out Jon Oxer’s shieldlist.org when researching your next Arduino shield – it is the largest and most comprehensive catalogue of submitted Arduino shields in existence.
[Note - the "Go Between" Shield was purchased by myself personally and reviewed without notifying the manufacturer or retailer]
Have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column, 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.
Project – Ultrasonic Combination Switch
In this project you learn how to make an ultrasonic distance-sensing combination switch.
Updated 18/03/2013
Time for a follow-up to the Single Button Combination Lock by creating another oddball type of switch/lock. To activate this switch we make use of a Parallax Ping))) Ultrasonic sensor, an Arduino-style board and some other hardware – to make a device that receives a four-number code which is made up of the distance between a hand and the sensor. If Arduino and ultrasonic sensors are new to you, please read this tutorial before moving on.
The required hardware for this project is minimal and shown below – a Freetronics Arduino-compatible board, the Ping))) sensor, and for display purposes we have an I2C-interface LCD module:
The combination for our ‘lock’ will consist of four integers. Each integer is the distance measured between the sensor and the user’s hand (etc.). For example, a combination may be 20, 15, 20, 15. So for the switch to be activated the user must place their hand 20cm away, then 15, then 20, then 15cm away. Our switch will have a delay between each measurement which can be modified in the sketch.
To keep things simple the overlord of the switch must insert the PIN into the switch sketch. Therefore we need a way to take measurements to generate a PIN. We do this with the following sketch, it simply displays the distance on the LCD (download):
// Ultrasonic combination lock - distance display // John Boxall - December 2011 // tronixstuff.wordpress.com/projects | CC by-sa-nc
#include "Wire.h" #include "LiquidCrystal_I2C.h" // for I2C bus LCD module http://bit.ly/eNf7jM LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
int signal=8;
void setup()
{
pinMode(signal, OUTPUT);
lcd.init(); // initialize the lcd
lcd.backlight(); // turn on LCD backlight
}
int getDistance()
// returns distance from Ping))) sensor in cm
{
int distance;
unsigned long pulseduration=0;
// get the raw measurement data from Ping)))
// set pin as output so we can send a pulse
pinMode(signal, OUTPUT);
// set output to LOW
digitalWrite(signal, LOW);
delayMicroseconds(5);
// now send the 5uS pulse out to activate Ping)))
digitalWrite(signal, HIGH);
delayMicroseconds(5);
digitalWrite(signal, LOW);
// now we need to change the digital pin
// to input to read the incoming pulse
pinMode(signal, INPUT);
// finally, measure the length of the incoming pulse
pulseduration=pulseIn(signal, HIGH);
// divide the pulse length by half
pulseduration=pulseduration/2;
// now convert to centimetres. We're metric here people...
distance = int(pulseduration/29);
return distance;
}
void loop()
{
lcd.print(getDistance());
lcd.println(" cm ");
delay(500);
lcd.clear();
}
And here is a demonstration of the sketch in action:
Now for the switch itself. For our example the process of “unlocking” will be started by the user placing their hand at a distance of 10cm or less in front of the sensor. Doing so will trigger the function checkPIN(), where the display prompts the user for four “numbers” which are returned by placing their hand a certain distance away from the sensor four times, with a delay between each reading which is set by the variable adel. The values of the user’s distances are stored in the array attempt[4].
Once the four readings have been taken, they are compared against the values in the array PIN[]. Some tolerance has been built into the checking process, where the value entered can vary +/- a certain distance. This tolerance distance is stored in the variable t in this function. Each of the user’s entries are compared and the tolerance taken into account. If each entry is successful, one is added to the variable accept. If all entries are correct, accept will equal four – at which point the sketch will either “unlock” or display “*** DENIED ***” on the LCD.
Again, this is an example and you can modify the display or checking procedure yourself. Moving forward, here is our lock sketch (download):
// Ultrasonic combination lock // John Boxall - December 2011 // tronixstuff.wordpress.com/projects | CC by-sa-nc
int pin[]={
20, 15, 20, 25}; // this is the "PIN" distances in cm
#include "Wire.h" #include "LiquidCrystal_I2C.h" // for I2C bus LCD module http://bit.ly/eNf7jM LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
int signal=8; // digital pin for Ping))) signal
void setup()
{
pinMode(signal, OUTPUT);
lcd.init(); // initialize the lcd
lcd.backlight(); // turn on LCD backlight
Serial.begin(9600); // for debug
}
int getDistance()
// returns distance from Ping))) sensor in cm
{
int distance;
unsigned long pulseduration=0;
// get the raw measurement data from Ping)))
// set pin as output so we can send a pulse
pinMode(signal, OUTPUT);
// set output to LOW
digitalWrite(signal, LOW);
delayMicroseconds(5);
// now send the 5uS pulse out to activate Ping)))
digitalWrite(signal, HIGH);
delayMicroseconds(5);
digitalWrite(signal, LOW);
// now we need to change the digital pin
// to input to read the incoming pulse
pinMode(signal, INPUT);
// finally, measure the length of the incoming pulse
pulseduration=pulseIn(signal, HIGH);
// divide the pulse length by half
pulseduration=pulseduration/2;
// now convert to centimetres. We're metric here people...
distance = int(pulseduration/29);
return distance;
}
void checkPIN()
{
int attempt[4]; // stores user's attempt values
int accept=0; // used for checking resulting user entry
int t=5; // +/- tolerance
int adel=1500; // delay between movement attempts
lcd.setCursor(0,0);
lcd.print("Get ready... ");
delay(adel); // delay before first distance measurement
lcd.setCursor(0,0);
lcd.print(" Position One ");
lcd.setCursor(0,1);
lcd.print(">>>>____________");
attempt[0]=getDistance();
delay(adel);
lcd.setCursor(0,0);
lcd.print(" Position Two ");
lcd.setCursor(0,1);
lcd.print(">>>>>>>>________");
attempt[1]=getDistance();
delay(adel);
lcd.setCursor(0,0);
lcd.print("Position Three ");
lcd.setCursor(0,1);
lcd.print(">>>>>>>>>>>>____");
attempt[2]=getDistance();
delay(adel);
lcd.setCursor(0,0);
lcd.print(" Position Four ");
lcd.setCursor(0,1);
lcd.print(">>>>>>>>>>>>>>>>");
attempt[3]=getDistance();
delay(adel);
lcd.clear();
lcd.print("Checking ... "); // for visual effect more than anything
delay(2000);
lcd.clear();
// display user entry on serial monitor for debugging
for (int z=0; z<4; z++)
{
Serial.println(attempt[z]);
}
Serial.println("------");
delay(2000);
// now compare against preset values
// allow a +/- tolerance (tolerance in integer 't')
if (attempt[0]>=(pin[0]-t) && attempt[0]<=(pin[0]+t)) { accept++; }
if (attempt[1]>=(pin[0]-t) && attempt[1]<=(pin[0]+t)) { accept++; }
if (attempt[2]>=(pin[0]-t) && attempt[2]<=(pin[0]+t)) { accept++; }
if (attempt[3]>=(pin[0]-t) && attempt[3]<=(pin[0]+t)) { accept++; }
if (accept==4)
{
// correct entry
lcd.setCursor(0,0);
lcd.print(" ** Accepted ** ");
// here you would enter code to run when the switch was successfully activated
delay(2000);
}
else if (accept!=4)
{
// incorrect entry
lcd.setCursor(0,0);
lcd.print(" *** DENIED *** ");
// here you would enter code to run when the switch was unsuccessfully activated
delay(2000);
}
}
void loop()
{
if (getDistance()<10)
{
lcd.clear();
checkPIN();
}
lcd.setCursor(0,0);
lcd.print(" ** Ready ** ");
}
To finish the switch, a housing similar to the unit shown below can be found, for example:
And for the final demonstration of the switch in action. Note that the delays between actions have been added for visual effect – you can always change them to suit yourself:
So there you have it – the base example for a different type of combination switch. I hope someone out there found this interesting or slightly useful.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.
Repurposing Cat5E Network Cable
Hello readers
Just some random notes from my Saturday afternoon. While cleaning up the garage I found a rather long network cable hiding from a long-forgotten project in the past:
However after trying to use it between my EtherTen and the router, the cable turned out to have a break in it somewhere. So what to do? Twentieth-century me would have just thrown it out, but that would be irresponsible. But inside that blue insulation are four twisted-pairs of 24AWG wire – perfect for prototyping and general low-voltage use:
So time to strip back the outer insulation and give the twisted-pairs their freedom:
They are a little thinner than first imagined, but how thin are they? Not being one to memorise the American Wire Gauge data I took a few quick measurements:
A quick measurement of the wire diameter without insulation. AWG specification is 0.511mm. Those digital vernier calipers were pretty sensitive so that will do. Excellent – now I have almost 120 metres of perfectly good hook-up wire. Just have to remember to test each piece before using it – that break was in there somewhere! What would that have cost me new? Local retailers (ugh) can charge over 25 centre per metre. So that’s a free lunch.
Next time you have some broken network cable… don’t throw it out – reuse it. What else can we do with the cable? Leave your suggestions in the comments below.
So have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column, 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.
Learn to solder with David L. Jones!
Hello Readers
How is your soldering? Have you always wanted to improve your soldering skills, or never heated an iron in your life and didn’t know where to start? No matter your level of skill you could do a lot worse than review the following video blogs in this article by David L. Jones.
Who?
[David] shares some of his 20 years experience in the electronics design industry in his unique non-scripted naturally overly enthusiastic and passionate style.
Bullsh!t and political correctness don’t get a look-in.Dave started out in hobby electronics over 30 years ago and since then has worked in such diverse areas as design engineering, production engineering, test engineering, electro-mechanical engineering, that wacky ISO quality stuff, field service, concept design, underwater acoustics, ceramic sensors, military sonar systems, red tape, endless paperwork trails, environmental testing, embedded firmware and software application design, PCB design (he’s CID certified), power distribution systems, ultra low noise and low power design, high speed digital design, telemetry systems, and too much other stuff he usually doesn’t talk about.
He has been published in various magazines including: Electronic Today International, Electronics Australia, Silicon Chip, Elektor, Everyday Practical Electronics (EPE), Make, and ReNew.
Few people know Dave is also a world renowned expert and author on Internet Dating, a qualified fitness instructor, geocacher, canyoner, and environmentalist.
Regular readers of this website would know that I rarely publish outside material – however the depth and quality of the tutorials make them a must-see for beginners and experienced people alike. Furthermore, if you have the bandwidth they can be viewed in 1080p. And as a fellow Australian I’m proud to support Dave and his efforts. So I hope you can view, enjoy and possibly learn from the following videos:
The first covers the variety of tools you would use:
And the second covers through-hole PCB soldering:
The third covers surface-mount soldering:
Finally, watch the procedure for soldering a tiny SMD IC using the ‘dead bug’ method:
And for something completely different:
If you enjoyed those videos then don’t forget to check out what’s new on Dave’s eevblog website and forum. Videos shown are (C) David L. Jones 2011 and embedded with permission.
As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts, follow on twitter, facebook, or join our Google Group.
[Disclaimer - I really enjoy the content at eevblog.com]
Otherwise, have fun, be good to each other – and make something!
Discovering Arduino’s internal EEPROM lifespan
How long does the internal EEPROM of an Atmel ATmega328 last for? Let’s find out…
Updated 18/03/2013
Some time ago I published a short tutorial concerning the use of the internal EEPROM belonging to the Atmel ATmega328 (etc.) microcontroller in our various Arduino boards. Although making use of the EEPROM is certainly useful, it has a theoretical finite lifespan – according to the Atmel data sheet (download .pdf) it is 100,000 write/erase cycles.
One of my twitter followers asked me “is that 100,000 uses per address, or the entire EEPROM?” – a very good question. So in the name of wanton destruction I have devised a simple way to answer the question of EEPROM lifespan. Inspired by the Dangerous Prototypes’ Flash Destroyer, we will write the number 170 (10101010 in binary) to each EEPROM address, then read each EEPROM address to check the stored number. The process is then repeated by writing the number 85 (01010101 in binary) to each address and then checking it again. The two binary numbers were chosen to ensure each bit in an address has an equal number of state changes.
After both of the processes listed above has completed, then the whole lot repeats. The process is halted when an incorrectly stored number is read from the EEPROM – the first failure. At this point the number of cycles, start and end time data are shown on the LCD.
In this example one cycle is 1024 sequential writes then reads. One would consider the entire EEPROM to be unusable after one false read, as it would be almost impossible to keep track of individual damaged EEPROM addresses. (Then again, a sketch could run a write/read check before attempting to allocate data to the EEPROM…)
If for some reason you would like to run this process yourself, please do not do so using an Arduino Mega, or another board that has a fixed microcontroller. (Unless for some reason you are the paranoid type and need to delete some data permanently). Once again, please note that the purpose of this sketch is to basically destroy your Arduino’s EEPROM. Here is the sketch to download.
If you are unfamiliar with the time-keeping section, please see part one of my Arduino+I2C tutorial. The LCD used was my quickie LCD shield – more information about that here. Or you could always just send the data to the serial monitor box – however you would need to leave the PC on for a loooooong time… So instead the example sat on top of an AC adaptor (wall wart) behind a couch (sofa) for a couple of months:
The only catch with running it from AC was the risk of possible power outages. We had one planned outage when our house PV system was installed, so I took a count reading before the mains was turned off, and corrected the sketch before starting it up again after the power cut. Nevertheless, here is a short video – showing the start and the final results of the test:
So there we have it, 1230163 cycles with each cycle writing and reading each individual EEPROM address. If repeating this odd experiment, your result will vary.
Well I hope someone out there found this interesting. Please refrain from sending emails or comments criticising the waste of a microcontroller – this was a one off.
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.















































