Programmable Music Box Essentials
www.kitronik.co.uk/2122
How the Music Box Hardware Works
The music box is based around an eight pin PIC micro-controller device. A PIC is, in effect, a small computer that
behaves in a way determined by the software that it’s programmed with. This software is generated by the user /
student. It is this code that will determine the eventual function of the project. To aid the design of this software, the
following describes the function of the hardware (circuit) that this software controls. From the music box circuit
above you can see that the PIC has two usable inputs and two usable outputs.
Input/Output
Pin
Connected to
Input 1
Pin 4, GPIO3
Switch
Input 2
Pin 3, GPIO4
Spare (connected to ‘INPUT2’)
Output
Pin 6, GPIO1
Spare (connected to ‘R3’ and ‘LED1’)
Output
Pin 5, GPIO2
Sounder
The other connections to the PIC are to provide it with power (V+ and Gnd) and also allow it to be programmed with
the user defined software (Pins 2 and 7).
Input 1
is connected to the micro-switch, using the common and normally
open connections. When this switch is not pressed, resistor R4 pulls the voltage on the input to the PIC to a low
voltage. When the switch is pressed (closed) the voltage on the PIC pin is pulled up to a high voltage. You will be able
to read this change of state in your software.
Input 2
has been left as a spare input should you wish to add another
input device. The pull down resistor R5, which is the same as that used on Input 1, would need to be added.
The sounder (buzzer) that has been used in the circuit does not have any drive circuitry. This means that it needs
driving with square wave (alternating high low voltage signal) to make it produce a tone. The frequency of the tone
will be the same as that of the square wave that is used to drive it. It is by varying this tone that the sounder can be
used to play a musical tune.
If you wish you can add an LED to the board, you will also need to add R3. The purpose of resistor R3 is to limit
(restrict) the flow of current into the LED. This controls the brightness of the LED and prevents it from becoming
damaged, which would happen if no resistor was used. We would suggest using a 330 resistor if you use a standard
LED.
One other point worth noting is the processor clock. For any micro-controller to work it requires a clock source. The
micro-controller uses this clock so that it knows when to execute the next line of software. Often these clocks are
generated externally but in the chip used in this circuit, the clock is built into the chip itself. This is why it does not
appear on the circuit diagram