012 030 1580   0 Items
How to: Solar charger module / step-up step-down module

How to: Solar charger module / step-up step-down module

solar charger module

Buck-Boost power modules have much application, from solar power to driving LED’s at a constant current.

It has lots of functions but number one is to supply a preset voltage, no matter if the voltage received is higher or lower than the supplied voltage.

If you set the voltage, as an example to 12V, it will keep the voltage constant even if it receives more or less than 12 V. It thus boosts voltage that is under the set voltage and decreases the voltage if it is above the set voltage.

You can, as an example, connect this unit directly to a 12V water pump, set the voltage to 12V and it will constantly drive this pump at that voltage. Even if the solar panel output voltage falls below the 12V or go higher than 12V.

buck boost power module

How to use this solar charger module. Written by Stepan Vosloo.

I recently got the chance to use the Solar charger module / step-up step-down power module. The heart of this module is the LT 3780EG IC from Linear Technologies, so, there is a lot of technical info about this module, to say the least.

I will spare you all the reading, and get straight to the point with this module. What is a Buck converter? Well, it can step down your voltage, eg. 12VDC to 4.20VDC (For those Li-ion batteries) What is a boost converter? Well, it can step up your voltage, eg. 7VDC to 12VDC. This module does both, from 1VDC to 30VDC (mine was 29.92VDC), I tested with a 13.87VDC 12A fully regulated power supply. At first, I didn’t expect too much of this little module, to give you an idea of how small it is, here a few pictures. The standoffs are not included.

If you look at the top picture, the pots are as follows:

Left-hand side potentiometer is used to adjust the Under Voltage Protection (VV) function. What does this mean? The device can monitor a DC-DC output voltage, and disconnect the power source from the DC-DC input load when an overvoltage condition occurs. A power-OK (Green) output signals when the DC-DC input voltage falls below an adjustable threshold. It is mostly used for solar charging.

The middle pot is Constant Current (CC), what does this mean? A constant current does not change its intensity over time, so it will stay constantly the same.

The right-hand side pot is Voltage Output (VOUT), what does mean? This is the pot that changes your output voltage from 1V to 30V……I got mine down to 0.8V. If you are not familiar with the Multiturn Trimpot Resistor, aka trim pot, get yourself a precision screwdriver that fits just perfect, I’ve had a few mishaps with thinking the screwdriver fits right, well, it doesn’t end well for your pocket or your voltage controller……  

How much power can it handle, and how efficient is it, you ask?

Well, I powered a 5W LED light from a single 3.7V Li-ion battery, without it even breaking a sweat…. I actually nearly blew it, because I pushed the voltage to just over 15V, but decided to bring it down after my son complained that the light was too bright Next up, was my 8W USB soldering iron…. according to the datasheets of these USB soldering irons, it requires just 1A at 5V, I normally use a 2A cell phone charger for this….it just works better, it heats up faster. Speaking of heating up faster, 15 seconds they claim for the USB soldering iron to be hot (450°C), with the LTC3780, you can expect reduced time to around 5-8 seconds! Yes, I kid you not. Soldering was more responsive, and quicker…..it heated up faster, when I soldered something with some weight like 24 AWG wires, not 1 or 2, about 10. I got bored pretty quickly though, as I kept the best for last  

Pushing its limits.

My TEC1-12708 12V 72W cold plate. Now, if you are not familiar with TEC units, they draw an immense amount of power. This particular bad boy draws a whopping 8.5A @ 12V, but on average it draws 6-8A, if you keep the voltage below the maximum threshold, which is 15.4V. I DO NOT RECOMMEND YOU USE IT AT THESE VOLTAGES! I have 4, so I am willing to put 1 at risk for testing purposes. I hooked it up to my W1209 thermostat, connected to a TEC cooler box, I needed to cool down a beer ASAP, just kidding, am I? anyway, temps came down to 2 °C, this was 15H00 in the afternoon. The LTC3780 had a little bit of trouble pushing a 72W TEC at 12V, the heatsinks actually heated up, now from what I understand, they almost never heat up. I have to add, I deliberately used a 3A 12V regulated DC PSU for this, I wanted to see the LTC3780 was capable of doing.

It really surprised me, and already have a few ideas in mind for an adjustable bench PSU. Sweet spot for efficiency is 98% at 12V @ 5A. All in all, well worth your money, most definitely. I use it for just about everything now.  

Reset the pots.

All pots can be reset to default by turning them anti-clockwise, for about 15 turns, the unit doesn’t need to be on, same for output voltage…. can be done without the unit being on. Do not get a fright when the FAULT LED is on when you switch on the unit, just adjust the pot clockwise, until the OK LED (Green) comes on…. this you will need to do whenever you change the input voltage.


What else can I say, go and buy one! Now….it will replace all your LM2956, XL4015 , PWM’s etc…. this module is really an all in one wonder, I LOVE IT.

RCWL-0516 microwave radar sensor review

RCWL-0516 microwave radar sensor review

RCWL 0516 radar sensor

Review: RCWL-0516 microwave radar sensor

I was made aware of this super cool radar movement detector a couple of months back from a guy that uses them as an alternative to light switches. With a light sensor and a simple delay, these sensors can control the switching of light when detecting movement. BUT that is not the most impressive feature of this sensor – because it is radar it can be placed behind all kinds of material like wood and ceiling boards and it will still work perfectly in detecting movement.

Just imagine, the unit is inside your roof and out of sight (the radar waves goes through the ceiling board without any problem). With a little bit of modification, you can hook it up to your alarm system as well. Now you not just have light control but also a super motion sensor for your alarm system that will detect intrusion in a room as well inside the ceiling of your roof!

These rcwl 0516 modules are really cheap, we have them available here.

I really like these units, you can connect them to a microcontroller digital pin or let them work all on their own. Yes, there are enough amps to drive an LED and/or a buzzer, adding a relay board (with a transistor to switch a relay) you can switch all kinds of equipment when movement is detected. Introducing a timer IC like a 555 will add delays to it.

Of cause, the jackpot will be a microcontroller like an Arduino (probably a bit of an overkill), even an Arduino Skeleton board might be an overkill but they are much smaller and cost less than half the price of an Uno.

It is a very easy unit to work with:

  • It’s got 2 power pins that you can supply anything from5V DC to 20V DC.
  • Then it got a TTL (signal pin) that is 0V if no changes are the environment is detected and 3.3V when changes are detected. If you are going to use a microcontroller you simply connect this pin to a digital input pin to monitor if the signal goes high and then programmatically do something if it does. The 3.3V signal is big enough to make an Arduino 5V pin go high as well. (You do not even need a microcontroller, there is enough power from the Sonar signal pin to drive a buzzer and LED)
  • It got a dedicated 3.3V Out pin to drive some other boards
  • A pdw pin. If you solder an LDR (light sensor) on the board you will get the output from the LDR on this pin. I have not tried it but you should be able to connect a resistor between the LDR pin TTL pin to keep the signal pin at 0V while there is daylight, making light control much easier.

The technology

The principle behind this sensor is simple, yet effective. It will send out RF signals in all directions and build up an electronic “picture” of the area from the signals that bounce back. This will continue happening until the “picture” changes that mean the signals bounce back differently. These changes happen because some object reflects it differently because it moved or entered the area. At this point, it will make the TTL line goes high and this new “picture” will now be stored. More movement and this new picture will be different and the same thing will happen.

Radar is used to detect metal and water. It will thus detect anything, like human bodies, that contain water. It will not detect movement of curtains for example, but don’t think it will not detect a human being that hides behind a curtain – it will.

This video below answers many questions on the tech itself:

RCWL-0516 pinouts

Pin Function
3V3 3.3V regulated output. Max 100mA (?)
GND Ground
OUT Trigger: high (3.3V) if motion detected. 0V normally.
VIN 4 – 28V supply voltage
CDS (light sensor related.. TODO)

RCWL-0516 sensor Application

This unit has much application in the security industry.

  • it works on true motion, not heat, in fact, heat lights and so on have no effect on the sensor
  • In my opinion the most important future, it can be used behind doors, boxes and so on. It can be hidden in cupboards and many places where it can not be seen to tamper with, including in the ceiling of your house.
  • it is omnidirectional so it gets the signals back in front and behind the sensor. It thus detects 5 meters in front and behind the sensor. Having this sensor on your ceiling will not just detect movement in the room but also the roof that is a favourite entry point for burglars.

Other applications coming to mind:

  • With the use of a day-night sensor and a timing circuit to keep the lights on, say for 10 minutes, after no movement is detected you can kiss your light switches goodbye. It will switch your lights on when you enter the room and off when no one is in the room – no worries about forgetting to switch lights off anymore.
  • Toys that do something cool when movement is detected.
  • Advertising displays that do something striking when somebody is near them.

Well, you are limited only by your imagination if you want “something” to happen when a person or anything else is moving.

These RCWL-0516 microwave radar sensor modules are available here

How to use a PH probe and sensor

How to use a PH probe and sensor

If you worked with PH metering before you will know that PH values range from 0-14. Where PH 0 Will be very acidic, PH 7 will be neutral and PH 14 very alkaline. Water is near a PH 7 and this is usually around here that we will need to monitor PH of many things. A swimming pool, for example, should be slightly alkaline at 7.2, hydroponics systems around 6 (for optimum plant nutrition takeup) and aquaponics around 6.8.

I wrote this PH probe and sensor “how to” because it is not as straightforward as one would think (but quite easy when you understand the ins and outs) mostly because there is not a lot of information on this on the Internet, surely not detailed information.

We will first look at the ph probe module board and then the PH probe because both the PH probe and sensor have to be set correctly:

  • offset setting
  • limit setting
  • sketch to test the board analogue range
  • sketch for PH reading and calibration.
  • calibration of PH probe
  • PH probe usage

The ph probe module in this tutorial is available on our site here: PH probe module BNC connector

ph probe sensor module

PH Probe Sensor Pinout
TO – Temperature output
DO – 3.3V Output (from ph limit pot)
PO – PH analog output ==> Arduino A0
Gnd – Gnd for PH probe (can come from Arduino GND pin) ==> Arduino GND
Gnd  – Gnd for board (can also come from Arduino GND pin) ==> Arduino GND
VCC – 5V DC (can come from Arduino 5V pin) ==> Arduino 5V pin
POT 1 – Analog reading offset (Nearest to BNC connector)
POT 2 – PH limit setting

PH probe module Offset and how to use it.

This board have the ability to supply a voltage output to the analogue board that will represent a PH value just like any other sensor that will connect to an analog pin. Ideally, we want a PH 0 represent 0v and a PH of 14 to represent 5V.

BUT there is a catch……, this board by default have PH 7 set to 0V (or near it, it differs from one PH probe to another, that is why we have to calibrate the probe as you will see later on), This means that the voltage will go into the minuses when reading acidic PH values and that cannot be read by the analog Arduino port. The offset pot is used to change this so that a PH 7 will read the expected 2.5V to the Arduino analog pin, the analog pin can read voltages between 0V and 5V hence the 2.5V that is halfway between 0V and 5V as a PH 7 is halfway between PH 0 and PH 14,

You will need to turn the offset potentiometer to get the right offset, The offset pot is the blue pot nearest to the BNC connector.

To set the offset is easy. First, you need to disconnect the probe from the circuit and short-circuit the inside of the BNC connector with the outside to simulate a neutral PH (PH7). I took a piece of wire, strip both sides, wrap the one side around the outside of the BNC connector and push the other side into the BNC hole. This short-circuit represents about a neutral PH reading of 7.

ph probe and sensor

ph sensor arduino connection

There are two ways you can do the adjustment.

If you have a multimeter handy you can measure the value of the PO pin and adjust the offset potentiometer until  PO measures 2.5V.

I prefer to just use the sketch below. Just download it to your Arduino as you will with any other sketch, open serial monitor and view the reading there. All this sketch does is to print the volts it receives from the analog pin and print it to the serial monitor. It of course first changes the digital value to volts to make it easier. Now simply turn the offset pot until it is exactly 2.5V. You can learn more about reading voltages and digital representation of volts here: https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage

Offset sketch

void setup() {
 // initialize serial communication at 9600 bits per second:

// the loop routine runs over and over showing the voltage on A0
void loop() {
 // read the input on analog pin 0:
 int sensorValue = analogRead(A0);
 // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
 float voltage = sensorValue * (5.0 / 1023.0);
 // print out the value you read:

PH limit setting

There is another pot that acts like a limit switch. Basically, the D0 pin on the sensor board will supply 3.3V to the pin until a preset PH value (that you set with the limit pot) is reached, at this point a red LED will light up and the pin will go down to about 0V.  I did not play with this much but suppose it can be handy if you want to activate a buzzer or something if a certain PH is reached, it will work great on an Arduino digital port – that will go high from about 2V up. This will work if the PH value goes higher than the set value. If you want it to trigger something when the PH goes lower, you need to monitor the digital pin to trigger when the digital pin goes low. You will unfortunately not be able to set this limit between two values, either if the pH goes up to high or if the PH drop to low. Programmatically you of cause can do an upper and lower limit.

Connecting and calibrating the PH probe.

The hard part is over and this offset does not have to be set again, even if you change PH probes. We have PH probes available here: PH probe Electrode BNC connector

Here is a couple of things to know about PH probes:

  1. The probes readings change over time and need to be calibrated every now and again to make sure the value is still the same and be adjusted if it did change.
  2. You need at least one PH buffer solution to calibration your PH probe. They are available at many different PH values, A buffer solution of 6.86 and 4.01 is most common as it covers the range of most applications. If you are only going to use one buffer solution make sure its value is near the value range you will use in your normal tests – if it is pool water a buffer solution of 6.86 is usually near enough.
  3. Buffers come in pre-made solutions or as a powder. I prefer the powder because it is cheaper and does not have an expiration date. The powder is easy to make up as well, I suppose it depends on the power you will use, the one I use you add the powder to 250ml distilled water and stir until all powder is dissolved. It will last about a month once you added water to it.
    buffer solution powder
  4. A PH probe takes some time to get to the right value, allow it to be in the liquid you want to measure for at least two minutes or longer, it does not mean it will be stable at one ph value, it will jump around a bit between 3 or 4 values but on the last digit, for example,  between 6.84 – 6.88
  5. PH values differ in different temperatures, although that might sound cumbersome, in the temperature range between 10 – 30 degrees Celcius the PH does not differ and from 30 degrees Celcius it goes up with about a pH of 0.01 to 50 degrees Celcius that is about 0.06. In most uses, it will be below 30 degrees Celcius and temperature do not have to be calculated in.

Hook up your PH probe after you removed the wire you used to short-circuit the BNC connector and download the sketch below.

PH measurement sketch

float calibration = 0.00; //change this value to calibrate
const int analogInPin = A0; 
int sensorValue = 0; 
unsigned long int avgValue; 
float b;
int buf[10],temp;
void setup() {
void loop() {
 for(int i=0;i<10;i++) 
 for(int i=0;i<9;i++)
 for(int j=i+1;j<10;j++)
 for(int i=2;i<8;i++)
 float pHVol=(float)avgValue*5.0/1024/6;
 float phValue = -5.70 * pHVol + calibration;
 Serial.print("sensor = ");

A note on buffer solutions: do not CROSS CONTAMINATE! What I mean by this is to not take the probe from one buffer solution to another or from a liquid sample you tested to a buffer solution without rinsing it thoroughly with distilled water first. You will change your buffer solutions ph and your calibration will be off.

When you place the probe in the first solution you might be surprised at how far off it can be, it’s normal though. Remember to leave the probe in the solution for at least two minutes to stabilise. In the script’s top line you will see a variable called “calibration”.  Change this value to the difference between what you see in serial monitor and the buffer solutions value, for example, if you read 5.81 and the buffer solution is 6.86 you should change the variable’s value to 2.05.

Upload the changed sketch and see how the value looks now.

Some ideas for you.

You can add a potentiometer to your project and program that to change the calibration for you. You always run a risk that the pot might be adjusted my mistake so a button with a 5-second delay can be programmed to put the unit in calibration mode.
This becomes great if you add an LCD screen to it and if you add the calibration value in EEPROM so it holds it even if the PH project is powered off.

How about adding a buzzer to the 3.3V limit output to notify you when the PH is out of range. Usually an upper or lower will be enough, in most applications, you will either be worried about high or low PH values but not both. If this is a problem and you need the PH to be in a certain range you can easily do that programmatically and have the buzzer on a digital pin. If it is crucial you can even add a GSM module to this so you can get an SMS or how about a dosing pump to automatically get the PH back in range.

I just might, but do not hold your breath (so much to do but so little time) :-), do something like that in the future with our cheap Skeleton Duino.

PH probe and sensor conclusion

If you go through these steps once it becomes as easy as pie. All the parts, even those I mention in the ideas section is available on our site.


Types of electronics power modules tutorial

Types of electronics power modules tutorial

power modules tutorial

The different types of electronics power modules tutorial and how to choose the right one for you.

If you click on our power supplies and modules category you will see many different power supplies and modules, there are adjustable ones, buck, boost, step-up, step-down, constant current, low power, high power and the list goes on and on. Hence this power modules tutorial.

The one thing all these different units have in common is that they all manage/change power in one way or another. Usually, they change a high voltage to a lower voltage, most commonly used power supplies also change AC current (from your house plug for example) to DC as required by most electronics. The popular 12V power supplies used on Arduino’s are a good example that changes AC to DC and lowers the 220V Volts to 12V

A power supply is a complete unit with wires inside a case where a power module is just the electronic circuit board.

Raspberry Pi Power Supply LM2596 Adjustable Step Down Power Supply module DC

In the rest of this power modules tutorial, I will refer to power modules but it is the same for power supplies.

The amps a power module can handle are probably the first thing you will look at when getting yourself one.

When developing projects we need more than a mere 12V power supply, we need to supply different power to different parts of a circuit and change it in ways to charge batteries and all kinds of other thigs, hence the big range of power modules.

When working with these modules you will often can a module that is bigger than the required input e.g. 12V for an Arduino Uno although all components require 5V and then from this supply make the voltages less as you go along.

Power usage

Once you decided on the voltage you will require you will need to think about the amps you will need. You need to understand that a voltage is supplied by a power supply and the wrong voltage will destroy your components but the amps it uses are drawn from the supply as needed by the components. Different components need more power than others.  One component might need 12V and 100mA and another 12V but 300mA. Together they will require 400mA.  The formula for power is V x A, thus you will need, in this example 12V x 0.4A thus a minimum of 4.8 Watt of power. Becuase amps are not ” pushed” into the circuit like voltage but “pulled” in as required by the components you can and should use a supply that can provide more than the required amps like a 1A supply. You want the supply to not work at its highest rating as to not put an unnecessary strain on them. An over worked unit will be very hot to the touch, a unit with amps to spare will be slightly warm to the touch.

Step-up, step down, buck and boost.

The word “buck” had me a bit confused when starting with these modules until I figured out it is just another word for step-down. A step-down unit just means you are going to make the volts less. This is done with a voltage regulator IC.

Boost is another word for step-up, this means you are going to make the supplied voltage more. This is done with devices called inductors.

To further explain these modules I will discuss a couple that is often used, why you will use them and shortly how to use them. As we explore some of these modules you will also learn about adjustable and constant current modules.

Adjustable 3A Ultra small power module

The most basic buck module, its small, can handle quite a big amount of current and its voltage can be adjusted.Adjustable 3A Ultra small power module

Way to the top right-hand side in the picture you can see the holes where you can connect your power source. The left side is where the adjusted power will be available to connect to your circuit. You should see the little adjustment pot that you will adjust to the correct required voltage, it’s the component near the bottom right next to the “+” sign.

This module is small but can deliver up to 3A and can adjust power sources between  4.5V to 28V down to
0.8V to 20V.

It is important to note that this unit itself uses a bit of voltage (as does most) to do the adjustment, normally around 0.8-2V, the higher the voltage is to adjust the more volts it uses itself.  You will thus need a voltage input that is 1-2V higher than what you want the output to be. If you use a 5V input you should easily get the unit to adjust between 0,8V and 4.2V, a 12V input 0.8V – 11V and so on.

to adjust these modules you need to hook it up to power and then use a multimeter on the output side to adjust the screw to the correct voltage.

You can look at the full specs here.

Adjustable Power step down module with Voltmeter

Next up is a similar module then discussed above, also a buck module,  but this one comes with a voltmeter for easy adjusting the power output without the need of a multimeter.

LM2596 Adjustable Power Converter

In fact, if you use a 12V 2A power supply with this product you have quite a neat desktop power supply. It has 2 buttons so you can check both the input and output voltages on the screen and small LEDs indicating if you are looking at input or output volts. These types of modules are best used as power sources while doing development, not final products (like the one discussed previously) except if your project will need a permanent voltage meter. I use them all the time while developing and testing products and the screw terminals are very useful to attach different products without having to solder them.

If you look at the components on this board you can see there is quite a difference compared to the first ultra small board we looked at. The main thing is that the ultra small board is as basic as they come to make the board as small as possible to incorporate them into final products. This board we look at right now is more expensive and another reason why I use them just as desktop power units to save on costs on final products.

However, they also use more powerful voltage regulators that can handle up to 40V input and 37V output for bigger voltage projects. It also has bigger stabilising capacitors that are very useful to have while developing higher voltage projects, stabilizing caps help to keep the output voltage very smooth even if the input voltage is not.

You can get all the specs for this module here.

AC-DC 220V to 12V power module

You do not need a bulky 220V to 12V power supply, especially if you are going to have a low power design.

This module takes 220V AC on the one side and supplies 12V DC on the other side. A WARNING though, you work with 220V power, it can kill you! But these modules are great when you insert them in your home build PC boards to make things look neat. I do not recommend them to new comers but introduce them here as part of the power modules tutorial as education. From this output, you can then add. for example. an ultra small step-down module to get the volts exactly where you want it to be just as you would with a normal 12V power supply.

More about these units here.

This concludes our look at basic power modules Next week we will look at more advanced modules in part 2 of this tutorial.


Skeleton Duino Review

Skeleton Duino Review

skeleton duino working

We designed this little board here at Bot shop as our solution to saving costs on using Arduino in our projects. Using an Arduino Uno on a finished project is firstly a bit expensive, throwing money in the water on components etc. not used in a final product. Secondly, the Uno board is unnecessary big for a final project that in itself mean bigger more expensive cases, thirdly it consumes unnecessary power (4x more than the Skeleton Duino) especially if you think of using batteries.

You can get one here.

You might be aware of the fact that in its basic form you just need the Atmega microcontroller, the crystal and 2 caps. A good idea is a 5V voltage regulator as well so you can use power sources bigger than 5V. The male rails, USB converter chip (quite expensive), 3.3V regulator, power jacks etc just add to cost and size of the board. All these are great while you develop but will not be used in a final product.  Jumper cables that fall out become a nuisance etc.

We use the Arduino Uno to develop our projects because it is easy to upload the code, push in jumper wires and get things to work. Once completed, we look at other boards for the final project. We used the Arduino mini but that is still a bit pricey and we do not like the SMD micro controller and having to go through the troubles of uploading sketches with an ISP uploader.

Eventually, we used strip board to have the Atmega, crystal and capacitors on a small board for projects but that looks nasty. Worth than that is building it on stripboard, the cutting away of tracks and soldering connection wires is a pain.

Here is an example of a pic from the Internet of such a board.
Uno stripboard

So we came up with the Skeleton Duino board. There is zero fluff, no USB to TTL to program the chip. no headers and a socket to plug in Atmega IC’s instead of the SMD chips.

Programming the Atmega micro controller

The whole idea is to program the chip on your Arduino Uno, take it out of the ic socket and then put it into the ic socket of the skeleton Duino. I hope it is needless to mention that you need the Uno with the micro controller in a socket not those with the Atmega SMD chip.  It does have a power LED, status LED and a 5V voltage regulator on board but that’s it.

Power consumption.

Unexpectedly actually, this board has quite a low power consumption because there are no additional voltage regulators. resistors, IC’s and so on. An Arduino

An Arduino Uno uses without anything connected to it 45 mA. The Skeleton Duino uses 9mA. This is important if you use batteries as a power source, they will last x 5.6 times longer.


  • The power terminals uses 2.54 pitch if you want to use screw terminals
  • 5V regulator
  • Power LED
  • Status LED
  • Dimensions: 45mm x 25mm
  • ……uh, ok that it.

We sell these boards on our site here.





Bot shop EL wire how to

Bot shop EL wire how to

Electroluminescent wire – EL wire how to

Yes, it looks impressive that is for sure! But it might seem a bit daunting to newcomers…… it is not. There are only a view things you need to know.

In the past, you needed to be quite skilled to use lighting to set moods, use in displays, in home decor and so on, now it became easy. In this EL wire how to you will learn everything you need to be an expert in electroluminescent products and it will take you no more than 15 minutes to learn.

Some quick technical stuff

el wire how its made

It is actually quite simple to understand. By introducing very low alternating current (but high voltage) to a layer of phosphor the phosphor will glow. Phosphor when glowing has an aqua blue colour.

To get different colours of EL wire a coloured plastic sleeve is used on the outside of the EL product. This is how EL product manufacturers can produce different colours

el wire colours

The colours are limited to 10 colours: Aqua (fluorescent blue), Lime (fluorescent green), red, blue, green purple, orange, yellow, pink and white

The way to introduce electricity to phosphor can be seen in the first picture above, you take a  piece of copper wire and coat it with phosphor, then you take 2 very fine wires and turn it around the phosphor coated wire like a spiral over the whole length of the wire. You now put the one wire of a power supply and connect it to the phosphor coated copper wire and the other wire of the power supply you connect to the 2 thin wires.

The power source – inverter

One of the reasons we did this how to is because there is a lot of confusion around the power requirements for electroluminescent. The first thing to know is that EL products operate best at a Voltage of between 80V-140V (120V is optimum).


If you touch bare open wires you might feel a very slight shock – so the connection points should never be exposed. Later in this how to you will see how to make your own connections (if you do not get pre-made el products with connectors already on them) and cover the bare wire with heat shrink tubes, We sell both types in our shop here.

The power source alternates the voltage at around 800 Hz. That simply means it first sends + voltage to the one EL wire and negative voltage to the other side and then switches the – and + voltages around, what is impressive is that it does this switching 800 times in a second, That’s fast!

To make this long story short – you need an EL inverter.

IMPORTANT. Inverters have different power ratings. The lower the power rating the smaller the length of EL wire it can handle. A small inverter is usually able to handle about 3 meters. You do not have to turn it into rocket science, you just need to be “nearish” to those specs, All inverters have a description on what length of EL wire it can drive

So be careful with this though, don’t use a short piece on an inverter that is meant for longer pieces, your EL product’s life expectancy will be drastically shortened. So basically if you have 3 meters or lower use a 3meter inverter rather, it will last longer

Power efficiency, heat and life span.

How long will it run from a battery and how many hours of light will it produce. EL products are very power efficient because of the low amps (current) it uses. There is no other light source this efficient.

Two AA batteries driving 3 meters of EL wire will last 10 hours plus!

No heat is produced at all, cold to the skin

EL wire life span is about 8000 hours, if you have it on every night it will last 1000 days

Using EL wire

El wire can be shaped any way you like. You can also cut it shorter and if you like you can put on connectors on the offcuts (more about that soon)

Becuase the EL wire got a plastic casing you can use PVC glue to glue it anywhere. For wearables like shirts and hats, you can sew it to the wearable by sewing a “loop ” around the EL wire and the piece of fabric. There are no hard and fast way on how to stick it to stuff, above is only ideas

Cutting and putting connectors on EL wire.

Easy as pie. Below is a video that shows exactly how to do that. You will need a soldering iron, solder and a wire stripper (or Stanley knife) we sell an El solder kit here that include the connectors, shrink wrap tubes and end caps. They use a heat gun in this video to shrink the tubes but a lighter will work great as well.

It is important to note that when you cut EL wire the end that is cut of must be isolated in any way you like so that the copper wire and 2 thin wires do not touch each other.



And that concludes this EL wire how to. So, head over to our EL wire shop category here, get some EL wire and accessories and create some fun stuff.

Our Lithium Battery Charging module review

Our Lithium Battery Charging module review

Lithium Battery Charging module

Lithium Battery Charging module

There will come a time that you want to have your project mobile. The easiest way to accomplish that is with batteries and if you want to get a bit fancy, rechargeable Lithium batteries.

I am reviewing the lithium Battery Charging module that is also available from us here. It is a low-cost unit that is affordable enough to build into your projects directly without having to worry to open a box, removing the batteries for charging and then put it all back again. Except for saving on the cost of a charger you now have an easy to charge project.

Power to the board.

It comes with a USB connector to connect to a 5V power source. This is handy because you can connect the module to a computer USB port or a 5V power supply, your cell phone power supply will work great. This module also has a place to solder 5V power supply power wires directly to the board as well.


Lithium charger functions

From the picture above you can see the 2 status LEDs on the Lithium Battery Charging module. The charge LED indicates that the battery is charging and the second LED lights up when the battery is fully charged.

Most of the work is done by the TP4056 IC, it is a constant-current/constant-voltage linear charger IC designed specifically for Lithium ion batteries and comes with many features including automatic recharging and is able to supply 1A charging current! You will find these chips in cell phones, cameras, charging doc stations etc.

Hooking it up is easy, supply the Lithium Battery Charging module with 5V and then hook up the battery via 2 wires to the bat+ and bat- power through holes on the board (this require soldering).


  • Input voltage: 5V
  • Maximum charging current: 1000 mA
  • Charge cut-off voltage: 4.2 V + / – 1%
  • Battery overcharge protection voltage: 2.5 V
  • Battery over-current protection current: 3 A
  • Input interface: Micro USB or 5V to power terminals
  • Dimension: 2.6 x 1.7 cm

Changing the charging current

Out of the box, this unit supply 1A constant current to the batteries but that might be too high. It is recommended that when you charge a battery you should charge them at 37-40% of the battery capacity(in mAh). If you are charging a battery of 1000mAh capacity, you should adjust the resistance in a way that the current offered is approximately 370mA-400mA.

Now, this is my only drawback in using this module, you will need to manually replace the resistor. It is an easy process but still a bit of extra work to get exactly the amps you require. I was hoping for a variable resistor but the problem with this is that you will blow the chip if you set the resistance too low, that you will do very easily if you turn a variable resistor just a bit too far to the wrong side.

In the picture earlier you can see the resistor you need to replace if 1A is too high for your batteries. It is easier than you probably think right now, simply use a soldering iron to heat up both sides of the resistor at the same time to remove, put the new one in place and heat up each side to solder it back in place. If you do not have an SMD resistor use a normal 1/4 watt resistor, cutting the legs as short as you can.

Here is a table to work out the size of the resistor you will require:

Resistor (k) BAT amps (mA)
30 50
20 70
10 130
5 250
4 300
3 400
2 580
1.66 690
1.5 780
1.33 900
1.2 1000


Cheap, easy to use and it can charge bigger Lithium batteries than expected with ease. With the drawback of having to solder in a different resistor to get the correct charging current comes the benefit of being able to charge any chargeable Lithium battery at its optimum levels.

Wemos D1 review  Wifi development board

Wemos D1 review Wifi development board

ESP-12E WeMos D1 review

Wemos D1 review

This board has quickly become our board of choice when we do Wifi project development. It looks just like an Arduino Uno and many Arduino shields will work with this board. We sell them here at Bot Shop – https://www.botshop.co.za/product/esp-12e-wemos-d1-wifi-board/

We created a scale project using this board, you can read more about the project here:

We pulled in a weight from scale sensors but without much changes, you can do the same with any type of sensor.

The D1 microcontroller is a beast compared to the Arduino Uno

The WeMos D1 uses the ESP 8266 microcontroller that is 2 x faster than an Uno, has 160Kbs of Ram compared to the 2K of an Uno and a 100x  the amount of  Flash memory! And each I/O pin is interruptable!

Most importantly is that it has embedded Wi-Fi and the centre point of this wemos d1 review.

Microcontroller specs

• A 32 bit RISC CPU running at 80MHz
• 64Kb of instruction RAM and 96Kb of data RAM
• 4MB flash memory
• Wi-Fi
• 16 GPIO pins
• I2S
• 1 ADC

The only area the Arduino chip is better is that it has 6 ADC’s and the D1 just one, although that will very seldom a problem as you have both I2C and SPI on the chip, it is still worth taking note of this. If you need more ADC’s it is easy to add a multiplexer to increase the amount of ADC’s.

Use your Arduino IDE to program the chip.

The Arduino IDE can be used to program the D1. The Wemos D1 have a USB to TTL chip on board for direct uploading of programs via USB directly from your PC. The chip used is the CH340G chip and unfortunately, a driver needs to be installed for some versions of Windows that does not include this driver. If your Windows version does not recognise the board it can easily be downloaded and installed, doing a Google search on “CH340G driver” will show many download links.

In this Wemos D1 review we do not want to go to much into details regarding programming but I have good links to follow, Also have a look at our scale project mentioned earlier in this review.

The next thing you will need to do is to add the Wemos D1 board to the list of boards already in the Arduino IDE. Here is an instructable on how to do that, it is pretty good http://www.instructables.com/id/Programming-the-WeMos-Using-Arduino-SoftwareIDE/

Oh, you will be able to upload to the board. To get the WiFi to work is not as difficult as I thought it will be, I used this instructable to do so: http://www.instructables.com/id/Programming-a-HTTP-Server-on-ESP-8266-12E/

Pin assignments

Something to note is that the pin assignment between the D1 and Uno is different. The Uno has the onboard led connected to pin 13 and the D1 to pin 14 as can be seen from the table below, If you, for example, upload the blink sketch to the D1 you will first need to change the sketch by replacing all calls to pin 13 to pin 14.

Wemos D1 pin assignments

Some things to be aware of.

  • As discussed the pinout differences, of cause the power pins are at the correct places.
  • Becuase of the pinouts some Arduino shields will not work out of the box, you will need to change the pin mappings. As an example, I had an LCD shield working in minutes without much effort.
  • The normal Arduino libraries will not always work, the LCD shield library worked with no problem though.

Wemos D1 review Summary.

Well, you can’t beat the price nor the ease of use. Microcontroller + Wifi for the same price as an Uno. I will always use my beloved Arduino Uno because of the amount of libraries and code available on the Internet but…. as soon as I need to use WiFi in my projects I will go for the Wemos D1 without a second thought. We also have a much smaller WiFI board for production here:

You can get yours from us here  https://www.botshop.co.za/product/esp-12e-wemos-d1-wifi-board/


Simple Arduino esp8266 web server ESP-07 ESP-12

Simple Arduino esp8266 web server ESP-07 ESP-12

Arduino esp8266 web server

To be able to host your own simple web server is easy all you need is the ESP8266 Serial WIFI Module and FTDI232 downloader here is a short description of both and a link on where to find it, An Arduino is not required at all and the ESP8266 board can be a stand alone board and it can be programmed with an FTDIboard. This blog is called Arduino esp8266 web server because you can also connect the wifi module to an Arduino if you want.

The ESP8266-03 is a highly integrated chip designed for the needs of a new connected world. It offers a complete and self-contained Wi-Fi networking solution, allowing it to either host the application or to offload all Wi-Fi networking functions from another application processor.

The USB to TTL serial adapter is based on the high quality and very popular FTDI FT232RL chipset and is an excellent way to connect TTL serial devices to a PC through a USB port and to program your Arduino esp8266 web server.

Unlike most USB to TTL serial adapters, this adapter supports both 5V AND 3.3V operation! Simply set the jumper as required to choose between 5V and 3.3V as labelled on the board.

Part List
  • ESP-07/ESP-12
  • FTDI232
  • Jumper Wires
  • 10k Resistor
  • Pushbutton
  • Breadboard
  • Stripboard
  • 2x 8 pin headers male or female
STEP1: Easy Access

Grab your headers, ESP module and strip board. Cut the Stripboard down to size (8 columns 9 rows), if you are unsure of the size you could cut it afterwards, remember to break the tracks at the bottom. Next solder thin wire to the pads of the ESP module and put each wire in its own column and solder it to the stripboard, next solder in the headers.

This part is very important because the pitch of the module’s pads are 2mm and that of the breadboard are 2.54mm.



STEP2: Wiring

Now we will look at the wiring of the module, something to keep in mind is that the module runs on 3.3V. The above mentioned Downloader(FTDI232) supports both 3.3V and 5V, switch the jumper to 3.3V if your downloader does not support 3.3v, you will have to add a voltage divider as shown below, below that is the wiring of the module.




STEP3: Setup

First things first, if you haven’t got the ESP8266 library yet see “Getting Started with NodeMCU with ESP8266 part 1” on how to install the library, next we have to select the type of board and programmer.

First select the Board Tools -> Board -> Generic ESP8266 Module


Next select the programmer Tools -> Programmer -> USBasp


Now you can connect your programmer and select the port. We’re using an example sketch for this tutorial. File -> Examples -> ESP8266WebServer -> Hello Server. Remember to add your SSID and password.


STEP4: Uploading

Now that the wiring is done and your Arduino IDE is set up, we can start the upload process.Uploading to the ESP module could become tricky if you don’t keep track so pay close attention.

Firstly  connect GPIO 0 to ground.


If the ESP module is powered up already, press the reset button you installed on the breadboard (pushbutton), if not just power up the module via the USB cable to the downloader. This process boots the  module up in program mode. You can now upload you sketch to the module. Once upload is complete, disconnect GPIO 0 from ground and reset it again, this allows the module to operate as normal. and your upload is complete.


STEP5: Connecting To The Server

When you are done uploading and you have removed the wire from GPIO 0 you can open your “Serial Monitor”. It should display the connection status after it has connected to your WIFI-router it will display an IP-address, copy this IP and enter it into your browser’s search bar. It will display the words “Hello From ESP8266” in your browser window.

Control with the Arduino bluetooth module

Control with the Arduino bluetooth module

We found this incredible tutorial on how to use the HM-10 BLE Arduino Bluetooth module by Hammad Tariq

connections_hn10_arduinoIn this tutorial, you will learn about controlling a LED using HM-10 BLE Arduino bluetooth module, Arduino and Evothings Studio.

Last Summer, I wrote a tutorial about controlling the lights of your home using Arduino and HC-05 bluetooth module. While, HC-05, HC-06 and HC-09 are still famous and available everywhere, they are essentially based on Bluetooth 2.0 technology. On the other hand, many new smartphones support only BLE (Bluetooth Low Energy or Bluetooth 4.0) instead of Bluetooth 2.0 or Bluetooth 1.0. The iPhone is most prominent of those smartphones as it’s supporting BLE since iPhone 4S, which was released nearly 5 years ago!

As I sat down to explore what options we have for prototyping a BLE enabled IoT device, the HM-10 came up as a prominent module in this space as it’s inexpensive and available everywhere. The module is also based on already familiar TI’s CC2541 BLE SoC. The module also has a few clones; one is called BT-05, another is called AT09, yet another is known as the SPP-CA HC-05/HC-06 or BT06, yet some clones are based on ZS-040 breakout boards just like HC-05.

There is an excellent post by Martyn Currey if you want to identify the module you have or want to explore the differences between them. Essentially, if your module is based on CC2541, that is BLE and you should be able to use this tutorial with the exception of UUID of the module, that I will explain later in the tutorial. Also, HM-10 and all other clones use AT commands for configuration, you can read the datasheets for reference but this tutorial or mobile app does not need you to use any AT command.

In addition to the HM-10 and Arduino, I will be using Evothings Studio to develop our mobile app. Evothings Studio is ideal for developing IoT mobile apps as it’s easy to use, gets you started in minutes even if you have “some” knowledge of JavaScript and HTML. Also, it has useful pre-built libraries and plugins, such as, for this example, the Evothings Studio already has necessary libraries to work with BLE, all you need is to write down a few lines of code to connect and send commands to your BLE module.

Step1: What you will need.




1 x HM-10 or anyother similar Arduino bluetooth module
1 x Arduino Uno
1 x LED
1 x 220 ohm resistor


Step 2: Connect the circuit



Connect the Arduino and Bluetooth module pins as shown below.

  1. Connect 3.3V of Arduino to the VCC of HM-10
  2. Connect GND of Arduino to the GND of HM-10
  3. Connect D8 of Arduino to RX of HM-10
  4. Connect D7 of Arduino to TX of HM-10
  5. Connect D2 of Arduino to the long leg of LED along with a 220 ohm resistor
  6. Connect the short leg of LED with the GND of Arduino


HM-10 and Arduino Wiring Diagram





Step 3: Upload the Arduino Sketch



Go to my Github repository and download/copy-paste the Arduino sketch to your Arduino IDE. Upload the sketch to your Arduino.

Step 4: Download the Evothings Studio

You can skip to next step if you already have Evothings Studio and are familiar with it’s working.

Follow these steps:

  1. Download and install Evothings Workbench on your computer. Generate an anonymous Cloud Key further down on the download page, paste it into the Workbench software.
  2. Download Evothings Viewer app from an appstore (iOS, Android)
  3. Open Evothings Workbench and click on “Get Key” button
  4. Open Evothings Viewer app, provide your connection key and tap the “connect” button
  5. Once the connection is successful, go to “Examples” tab and click the “Run” button for the “Hello World” example

You should see the “Hello World” app loaded into the Evothings Viewer; that is how the whole development suite works together, whatever changes you will make in your app code, the Evothings Workbench will reload it in the Evothings Viewer, allowing you to preview your changes in real time!

Step 5: Developing the Mobile App

On Evothings Workbench, click “Run” for “BLE Scan” example and note down the name of your BLE module.

Clone or download this Github repository on your computer. Open “hm10-arduino-ble” example, go to “app folder”, drag & drop the “index.html” to “My Apps” tab of Evothings Workbench.

Now open “index.html” in your favourite code editor, check “app.connect” function to confirm if your module has the same name as written in the code, else change it with your module’s name.

Now click the “Run” for your new project entry in “My Apps” tab, the app should load in Evothings Viewer, press the “Connect” button. Once connected, use the buttons to switch your LED On/Off.

Tip: If you experience any difficulty in connecting with your module, first identify which module do you have and then search for it’s UUID (universal unique identifier) online. Correct UUID should be given in the app.ledOn and app.ledOff functions of index.html.

Code Explanation

As explained earlier, the Evothings Studio comes bundled with all necessary libraries to connect and get you started with BLE. Our example is making use of arduinoble and easyble libraries which are located in app/libs/evothings directory. See this tutorial on more details about them. As, for now, we don’t need to go in detail of how these libraries are working, we can just focus on the code in the “index.html” file.

Following block of code is used to connect to the BLE module:

app.connect = function()
'BT05', // Name of the module.
app.device = device;
app.showMessage('Connected! Touch buttons to turn LED on/off.');
app.showMessage('Connect error: '   errorCode   '.');

In this block of code, we are providing the name of the module to the library function of evothings.arduinoble.connect, upon success, we show a success message.

Similarly, analyze following block of code:

// Turn on LED.
app.ledOn = function()
app.device && app.device.writeDataArray(new Uint8Array([1]), '0000ffe1-0000-1000-8000-00805f9b34fb');
// Turn off LED.
app.ledOff = function()
app.device && app.device.writeDataArray(new Uint8Array([0]), '0000ffe1-0000-1000-8000-00805f9b34fb');

In this block of code, we are calling library function app.device.writeDataArray to write 0 and 1 to the BLE module along with the UUID of HM-10 module.

In the Arduino sketch, analyze the following block of code:

void loop() {
int c;
if (mySerial.available()) {
c = mySerial.read();
Serial.println("Got input:");
if (c != 0)
// Non-zero input means "turn on LED".
Serial.println("  on");
digitalWrite(LED_PIN, HIGH);
// Input value zero means "turn off LED".
Serial.println("  off");
digitalWrite(LED_PIN, LOW);

In this block of code, we are reading the software serial of Arduino. We simply switch the LED on if we receive anything other than 0 on the software serial, similarly, if it’s 0, we turn the LED off.

You can also check the serial monitor of Arduino IDE to see what you are receiving on Arduino’s software serial.

IOT modules with NodeMCU with ESP8266 WiFI part 1

IOT modules with NodeMCU with ESP8266 WiFI part 1

The ESP8266 WiFi chip

The first thing you need to know is that the ESP8266 WiFi chip is much more than just a WiFi chip. It also includes its own microprocessor, 16 input/output pins, 64 KiB of instruction RAM and 96 KiB of data RAM.

The ESP8266 wifi chip can me run as a serial device from an Arduino but it can also be used as a stand-alone device!

You can use this chip on a breakout board with a couple of components to create a stand-alone Internet Of Things device. This is much more cost effective than an Arduino with a WiFi shield. IOT esp8266 WifI devices became very popular these days because of the amazing benefits included in the ESP chip.

Thanks to the guys who ported the Esp8266 into Arduino IDE and helping all the Arduino users to easily program the ESP8266.

Most of this NobeMCU part 1 post discusses how to install the Esp8266 support for the Arduino and then a short script on how to blink a LED (the hello world in the electronics).

Firstly open the Arduino IDE and then go to the file menu and click on the preference sub menu in the Arduino IDE

Copy the below link into the Additional boards Manager URLs


Click OK to continue.

After completing the above steps , go to Tools -> board, and then select Boards Manager

Search for ESP8266 in the search bar and install “ESP8266 by ESP8266 Community”.

Once all the above are completed we are ready to program our esp8266 with Arduino IDE.

For this example I have used NodeMCU esp8266, if you are using any other vendor wifi chips or generic wifi module please check with the esp8266 Pin mapping which is very essential to make things works.

The reason why I used D7 pin for this example is , I uploaded the basic blink program that comes with the examples program in the arduino IDE which is connected with 13 pin of arduino. The 13th pin is mapped into D7 pin of NodeMCU.

Go to the tools menu and then the board sub menu and select the type of esp8266 you are using and select the correct COM port to run the program on your esp8266 device. For the Node MCU, select NodeMCU 1.0 (ESP-12E Module)


void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);

// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second

Part 2 of this block post can be found here.

Pulling Larger Loads with Arduino Mosfet

Pulling Larger Loads with Arduino Mosfet

Arduino Mosfet layout

If you are anything like me, this simply is not enough!

No, you want to use this on your next Arduino project, but these LED’s need lots of power.

The Arduino only supplies 5V and even if it’s a large 5V device the maximum current per I/O pin is 40mA, a normal red LED is already 20mA, so you can see that the Arduino can’t power much larger devices without cause trouble to some extent, but there is a solution to this problem, that doesn’t put unnecessary strain on the Arduino. No, it’s not a relay, because a relay is either on or off and we might want to dim our power LEDs. And then there’s the clicking noise produced from relays as well. I’m talking about Mosfets. Arduino Mosfet circuits are easy and quite cheap to build.

I used the IRL520N N-channel logic Mosfet which is suitable for PWM’s as well. If it isn’t a logic Mosfet the Arduino will not be able to open it fully because a normal Mosfet requires more than 5V to open fully and you will not be able to supply the full 12V to the LED.

A logic Mosfet will supply the full input voltage to the device or component you want to drive from your Arduino. An Arduino Mosfet circuit can be created with nonlogic Mosfets but an additional transistor will be required to drive the gate.

The IRL520N can handle up to a 100V and 10A. It is DC device and will be able to drive most high load devices with ease.


The Multi-function shield for Arduino

The Multi-function shield for Arduino

Arduino Multi-function shield

This Arduino Uno and Leonardo compatible multifunction experimenter shield (HCARDU0085) has a large range of features which makes it ideal for beginners who just want to experiment and learn, or just as a general purpose shield for more advanced uses. Besides the feature rich range of components fitted to the shield, there are also a range of expansion headers for convenient interfacing of external modules and components. The shield includes R3 type headers for easy connection to your Arduino board. If you have a pre R3 design board please check for compatibility before purchase.

Please note: Before applying power to your Arduino board check that other than the header pins, no part of the underside of this shield is in contact with the host board. This shield includes a header for attaching an IR reciver (U4-IR-2). The pinout order is not suitable for direcly connecting a SFH506-38. However the order is compatible with our 1838B Infrared IR receiver (HCSENS0014). Please always check the attached schematic before connecting external components.

The Multi-function shield is a compact experimenting shield packed with features.

Some of Arduino Multi-function shield features include:

4 digit 7-segment LED display module driven by two serial 74HC595’s
4 x surface mount LED’s in a parallel configuration
10K adjustable precision potentiometer
3 x Independent push buttons
Piezo buzzer
DS18B20 temperature sensor interface
LM35 temperature sensor interface
Infrared receiver interface
Serial interface header for convenient connection to serial modules such as Bluetooth, wireless interface

We found this on Youtube

Clock Sketch


button 1 : hold to set time or alarm
button 2 : press to view alarm time or cancel alarm if in progress
button 3 : increment hour / minute when setting (alarm) time. Hold to toggle alarm setting.

LED1 : on = alarm enabled

volatile unsigned int clockMilliSeconds = 0;
volatile byte clockSeconds = 0;
volatile byte clockMinutes = 0;
volatile byte clockHours = 12;
volatile byte clockEnabled = 1;

byte alarmMinutes = 30;
byte alarmHours = 6;
volatile byte alarmEnabled = false;

byte alarmTogglePressed = false;

enum displayModeValues

byte displayMode = MODE_CLOCK_TIME;

void setup()
MFS.userInterrupt = clockISR;


void loop()
// put your main code here, to run repeatedly:

byte btn = MFS.getButton();

switch (displayMode)
displayTime(clockHours, clockMinutes);

if (btn == BUTTON_2_PRESSED)
MFS.beep(0); // cancel the alarm.
displayMode = MODE_ALARM_TIME;
else if (btn == BUTTON_1_LONG_PRESSED)
MFS.blinkDisplay(DIGIT_ALL, OFF);
MFS.blinkDisplay(DIGIT_1 | DIGIT_2);
clockEnabled = false;
clockMilliSeconds = 0;
clockSeconds = 0;
else if (btn == BUTTON_3_LONG_PRESSED && !alarmTogglePressed)
alarmTogglePressed = true;
alarmEnabled = !alarmEnabled;
MFS.writeLeds(LED_1, alarmEnabled);
else if (btn == BUTTON_3_LONG_RELEASE)
alarmTogglePressed = false;

if (btn == BUTTON_1_PRESSED)
MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);
MFS.blinkDisplay(DIGIT_3 | DIGIT_4);
else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
if (clockHours >= 24)
clockHours = 0;
displayTime(clockHours, clockMinutes);

if (btn == BUTTON_1_PRESSED)
MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);
displayMode = MODE_CLOCK_TIME;
clockEnabled = true;
else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
if (clockMinutes >= 60)
clockMinutes = 0;
displayTime(clockHours, clockMinutes);

displayTime(alarmHours, alarmMinutes);

displayMode = MODE_CLOCK_TIME;
else if (btn == BUTTON_1_LONG_PRESSED)
MFS.blinkDisplay(DIGIT_ALL, OFF);
MFS.blinkDisplay(DIGIT_1 | DIGIT_2);
alarmEnabled = false;

if (btn == BUTTON_1_PRESSED)
MFS.blinkDisplay(DIGIT_1 | DIGIT_2, OFF);
MFS.blinkDisplay(DIGIT_3 | DIGIT_4);
else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
if (alarmHours >= 24)
alarmHours = 0;
displayTime(alarmHours, alarmMinutes);

if (btn == BUTTON_1_PRESSED)
MFS.blinkDisplay(DIGIT_3 | DIGIT_4, OFF);
displayMode = MODE_CLOCK_TIME;
alarmEnabled = true;
MFS.writeLeds(LED_1, ON);
else if (btn == BUTTON_3_PRESSED || btn == BUTTON_3_LONG_PRESSED)
if (alarmMinutes >= 60)
alarmMinutes = 0;
displayTime(alarmHours, alarmMinutes);

void displayTime (byte hours, byte minutes)
char time[5];

sprintf(time, “%03d”, (hours * 100) + minutes);
MFS.write(time, 1);

void clockISR ()
// Perform ripple count for all time components.
if (clockEnabled)
if (clockMilliSeconds >= 1000)
clockMilliSeconds = 0;

if (clockSeconds >= 60)
clockSeconds = 0;

if (clockMinutes >= 60)
clockMinutes = 0;

if (clockHours >= 24)
clockHours = 0;

// If current time coincides with alarm time, and alarm is enabled, engage the alarm.
if (alarmEnabled && (clockMinutes == alarmMinutes) && (clockHours == alarmHours))
10, // on period
5, // off period
4, // number of cycles
100, // number of loop cycles
50 // delay between loop cycles