Introduction: LittleBits Light & Ultrasone Controlled MIDI Sound Instrument

About: my inventions

In this instructable I will show how you can use the LittleBits W6 Arduino Leonardo bit to make music via the MIDI protocol.

This instructable is an updated version of my first instructable with LittleBits and MIDI, see

https://www.instructables.com/LittleBits-Light-Controlled-MIDI-Sound-Instrument/

This updated instrument uses two light sensors (for instrument/vibrato selection and for tempo selection) and an ultrasonic distance sensor type HC-SR04 for the pitch selection.

The Arduino can send MIDI signals to an attached laptop via USB. This PC uses software to convert these signals into sound. I based my design on the free software sound program VMPK (Virtual Midi Piano Keyboard), combined with VirtualMIDISynth from CoolSoft (also a free progam). MIDI means Musical Instrument Digital Interface: a standard means of sending digitally encoded information about music between electronic devices, as between synthesizers and computers.

Supplies

Littlebits parts:

1 mounting board

2 powersnaps

3 bitsnaps

1 W6 Arduino bit

2 I13 light sensors

1 O3 RGB led bit

1 P1 power bit

1 W9 proto bit

Other parts:

1 ultrasonic distance sensor type HC-SR04 incl. 4x male-female wiring

1 USB cable for power and data

1 12 VDC power supply

1 laptop PC with VMPK (Virtual MIDI Piano Keyboard) & Virtual MIDI Synth soundfont software

Step 1: How Does It Work ?

The W6 Arduino has three input connections and three output connections.
A few more input/output connections are also available onthe surface of the board. On input A0 a light sensor is connected to control the tempo of the music tones. On input A1 a second light sensor is connected to select the instrument you will hear and the vibrato setting. I selected 16 instruments out ot the 128 available that will play very nice sounds using this Littlebits setup. On output D5 a RGB led is connected (set to blue color) to show the vibrato ON/OFF setting. The ultrasonic sensor is connected to D10 and D11 (trigger and echo) and on the protobit on D1 for 5 VDC power supply. The USB from the W6 Arduino is connected to the PC. The software will change the MIDI data from the Arduino into sounds. First you must download the attached Arduino ino program and upload it into the W6 module. Install both MIDI software programs VMPK and VirtualMidiSynth as explained on their websites. You can test the installation by using the virtual keyboard on screen. When done, power up the Arduino. After powering up start the VMPK program. This sequence is important, if you start the MIDI software first you will hear no sounds at all from the W6 Arduino.

Step 2: The Arduino Program

The program uses the MIDIUSB library which is included in the Arduino IDE (Integrated Development Environment).

The light level on input A1 for the instrument selection is detected and changes the step value between 0 and 15 which selects the instrument in the instrument array. An even number also sets the vibrato ON and an odd number sets the vibrato OFF. This also triggers the RGB blue led ON/OFF.

The ultrasone sensor detects the distance between the sensor and your hand and this value can vary between 0 and 25 cm. This value is changed into tone values between 24 and 96.

The light level for the tempo setting on input A0 (0-1023) is transferred into a level between 2 and 500.

The MIDI notes are played with a delay set by the tempo value. Three notes are played at the same time to make the sound more interesting.

There are four subroutines used for noteON, noteOFF, controlChange (for the vibrato effect) and programChange (to select an instrument). There is also a deactivated debugging section you can activate and use to see some values on the Arduino screen monitor if needed.