In those two articles, the littleBits electronics module construction was presented along with enhancement techniques for adding an external speaker to the infrared (IR) operated audio oscillator. The Proto Bit introduced in the oscillator project allows such enhancements to occur your own circuits to work directly with the littleBits electronic modules.
In this article, I will show you how to build a simple music machine using littleBits modules, including a codeBit, speaker Bit, power Bit, Proto Bit, and a push button Bit.
We will cover the blocky codes for playing musical tunes (in this case Mary Had a Little Lamb) and for observing the music waveform produced using a mini oscilloscope. These codes will also be available at the end of the article.
The simple music machine needs five basic littleBits electronic modules:
- power Bit
- push-button Bit
- Proto Bit
- speaker Bit
The bits will snap together in a single line allowing the construction of the musical device.
A 9V battery is also required to power your device.
Building the Simple Music Machine
To build the simple music machine you must secure the littleBits electronic modules shown in Figure 1 in proper order. The block diagram in Figure 2 shows the correct order for the littleBits modules.
Following the correct order for snapping the littleBits together is very important, because it shows the musical device's waveform signal using an oscilloscope. The oscilloscope will attach to the Proto Bit allowing us to see the waveform signals produced by the codeBit tones.
Figure 3 shows where you will attach an oscilloscope in the Proto Bit to view the codeBit music tones’ waveform signal. An analog DC voltmeter can also be attached to the Proto Bit to create a volume unit (VU) meter or metronome effect for the musical device.
To ensure proper electrical connectivity is established between the bits, slightly press the electronic modules together when they snap into place. You can test the simple music machine’s electrical connections by powering the device with a 9V battery. Slide the power Bit’s small slide switch to the ON position, and the red LEDs on the power Bit and codeBit will light up.
With both LEDs on, your device is ready for programming. Here’s the completed music machine I built including a mini oscilloscope attached to the Proto Bit.
I included a latch bit to allow the music to continually play from the device.
The heart of the simple music machine is the codeBit.
The codeBit is a small programmable circuit that allows you to create a variety of devices including robots, electronic games, toys, and even smartphone operated radios.
If you are an educator, the codeBit is a great instructional tool for integrating technology into your classroom. With the codeBit, you can introduce coding concepts and electronics into your classroom with STEM and STEAM curriculum.
If you flip the codeBit over, you can see a small black square microchip along with other tiny electronic parts mounted on the printed circuit board (PCB). The microchip is an ATSAMD21 32-bit microcontroller (Figure 6). The microcontroller allows for adding programming code features and functions to the codeBit.
The layout of the ATSAMD21 microcontroller on the codeBit’s PCB is based on an input/output (I/O) design scheme of 3 and 3. There are 3 inputs and outputs connectors. One of the output connectors (out 1) is designated for driving a littleBits LED matrix.
If you are not using the LED matrix, then out 1 can be used for driving other littleBits electronic modules like a bar graph, motors (servo and DC), and LED displays. Figure 7 shows the arrangement of the littleBits codeBit I/O connectors.
The Blockly Code
The code used to play Mary Had A Little Lamb was built using Blockly code.
Blockly code is a software development product developed by Google to allow novice Makers unfamiliar with coding to create programmable devices. The programming instructions are embedded in colorful blocks. These blocks instruct the codeBit to perform dedicated tasks.
With this mini Blockly code training session, you will have the skills and knowledge to understand and modify the codeBits Blockly code shown in Figure 9.
Programming the codeBit
To program the codeBit, connect a USB cable between the codeBit and your laptop computer or desktop PC.
The codeBit software is a free download and can be obtained from the littleBit’s download page.
Once you install the software and attach the codeBit to your laptop computer or desktop PC, you are ready to code the musical tune shown in Figure 9. To upload the code, click the Upload button in the lower right-hand corner of the window (Figure 11).
When the codeBit begins receiving the program, a small green LED on the Bit starts to flash.
After uploading the program to the codeBit , adjust the volume on the speaker bit and press the push-button Bit. You will hear the musical tune playing through the speaker Bit. Congratulations on building your simple music machine!
With each press of the push-button Bit, you will hear the tune through the speaker and see a square wave visible on the attached oscilloscope. The frequency measured is around 165 Hz. Explore the code by changing the notes and observing the change in frequency.
To take this project further, you can purchase different input bits to create unique human interaction controls with the simple sound machine. In a future article, I’ll show you how to add your own electronic circuits to a littleBits device using the Proto Bit.