Simple PIC LED toy

1  Overview

One day I decided to do some small light emitting toy myself, except buying something like that. It was for my (at that time more than one year old) son. After spending few hours by searching the internet for some do it yourself (DYI) LED toy fitting my expectations without a success, I realized it was a waste of time. I found easier to develop something myself than wasting additional time by googling. So here is some of my knowledge and skills delivered into DYI cheap simple pic LED toy.

I wanted to have flexibility in changing future behavior - microcontroller based solution was a clear choice.
PIC12F629 looks great to fit for purpose:

All enough to handle some small code with some LED lighting effects.

2  HW

2.1  Schematic

Core component of a circuit diagram is the PIC12F629 powered by a 3 V battery. For light effects there are used 4 LEDs with different color. Light effect is activated by a push button.

Figure 1: Schematic of a simple PIC LED toy.

C2 should be physically as closest to IC1 as possible.
C3 is important - it protects IC1 against stopping working / freezing. Push button S1 generates bounces with spikes on GP2 input. Looks like it destabilizes PIC and it freezes program execution then. I suppose that spikes generated by push button gets far over 3 V and thus destabilize internal PIC electronics. C3+R5 helps with this. This push button issue depends on a type used. S1 type that I used does producer not intended to use with microcontrollers.
As GP3 is input only pin, it is safest to connect it to GND to prevent electrostatic charges destabilizing PIC (similar issue like GP2 input).
C1 is not so important if battery holder does not interrupt power supply on shocks that may occur (falling, throwing).
LED1-4 could be any LEDs you will find at home. It may be need to increase R1-4 value to 100 Ω based on your LED type. I had some old LEDs with high UF value.

All used passive circuits were (recycled) from home depot. I just needed to buy PIC12F629.

Scheme has so low circuits that it does not need PCB (printed circuit board). I used socket for IC1 and rest of circuits are soldered around it. Socket enables PIC removal and ICSP programming on solderless breadboard. The thing is, that you need 5 V for ICSP programming because 3 V is not enough (see datasheet). For 5 V power supply there are needed higher R1-4 values to avoid LED1-4 destruction.

Final LED toy I packaged into tic-tac box due to these reasons:


Figure 2: Simple PIC LED toy in a tic-tac box

So total costs of a toy was in my case just cost of a PIC12F629. Very cheap one.

2.2  Safety

From safety point of view - there is no risk of electrical injury for children, because of low power supply voltage from 3 V battery source.

It is important to put a toy in a safe package - well screwed / using enough transparent tape to avoid children to get inside and eat some circuits.

3  SW

Simple PIC LED toy SW is developed in C programming language using Microchip MPlabX IDE (v4.01) and Microchip XC8 compiler (v1.44).

Actual SW version:


PIC LED toy SW source code and HEX files you can download all packed in

It is provided
just for non-commercial purposes only.

4 Programming

For programming & development I used:

If you do not have PICkit™ 3, you can use:

5  License, warranty, legal notice

Complete "Simple PIC LED toy" is available free of charge for non-commercial purposes.
Building a toy is on your own risk, I am not responsible for any damages and injuries caused by using any information published here.
Anything provided here is without any warranty & support.

6  Final words

In case all LEDs are permanently lighting, no matter if button is pressed, this could be caused by a low battery voltage. Try to remove and put back battery - if LEDs keep permanently lighting after battery insertion, you need to replace battery. Brown-out Detect (BOD) functionality keeps PIC in RESET if power voltage (typically) drops below 2.1 V.

If you found these information useful, please consider to:

This will allow me to bring more interesting projects for you.