Skip navigation

With the program now written and working is was now time to compete the final circuit and housing for the interface.  This will be done with Vera-borad and a sturdy plastic box.

It had been decied that an over-sized plastic box would be used as this would give me plenty of room to work with and would also mean that there would be enough room to connect the Arduino to the USB cable to allow for re-programming in the future.


Below is the program i have written to convert voltage readings into MIDI data.

The brief and general nature of the program is as follows:

The Arduino checks the current state of each flex sensor when initialised

The Adruino then checks the state of the flex sensors on a contunious loop

If the state of the flex sensors has changed (becomes bent) then the Arduino will send the intended MIDI note

There is a short delay before the Note-off command is sent

The duration of the note (or length of delay) is dependant on the Y axis of the Accelerometer

The pitch of the note is dependant on the X axis of the Accelerometer

(it is worth noting that the very last lines of the program are an essential part of the program however i’m not entirely sure what it does but the program does not work without it!)


Arduino Program

// Program to read analog inputs and convert this to MIDI data before sending to DAW via USB

// Name PINS

int F1 = A0;

int F2 = A1;

int F3 = A2;

int F4 = A3;

int AX = A4;

int AY = A5;

// Names for Actions

int flex1;

int flex2;

int flex3;

int flex4;

int accelx;

int accely;

int flexState1;

int flexState2;

int flexState3;

int flexState4;

int accelStatex;

int accelStatey;

// Runs once when initialised

void setup() {

Serial.begin(31250); // MIDI runs at this rate (31250)

pinMode(A0, INPUT); // Designating PINS as INPUTS

pinMode(A1, INPUT);

pinMode(A2, INPUT);

pinMode(A3, INPUT);

pinMode(A4, INPUT);

pinMode(A5, INPUT);

flexState1 = analogRead(F1); // read the initial state

flexState2 = analogRead(F2);

flexState3 = analogRead(F3);

flexState4 = analogRead(F4);

accelStatex = analogRead(AX);

accelStatey = analogRead(AY);


void loop(){

flex1 = analogRead(F1);   // read input value and store it

accelStatex = analogRead(AX);// read input from x axis

accelStatey = analogRead(AY); // read input from y axis

int mapped = map(accelStatex,600,200,60,127); // map x reading to between 60 – 127

int Ymapped = map(accelStatey,600,200,250,1000); // map y reading to between 250 – 1000 (1/4 sec – 1 sec)

if (flex1 < flexState1) {          // the flex state has changed?

if (flex1 < 395) {      // check if the flex sensor is bent

SendMidi (0x90, mapped, 120);// then send Note-on (Note-on, Note, Velocity)


delay(Ymapped); //hold note duration by y mapped (250-1000)


SendMidi (0x80, mapped, 120); // send Note-off



// Repeat will all flex sensors…..

flex2 = analogRead(F2);

accelStatex = analogRead(AX);

accelStatey = analogRead(AY);

int mappedF2 = map(accelStatex,600,200,60,127);

int XmappedF2 = map(accelStatey,600,200,60,127);

if (flex2 < flexState2) {

if (flex2 < 395) {

SendMidi (0x90, mapped +1, 120); // +1 to give a range of notes




SendMidi (0x80, mapped +1, 120);



flex3 = analogRead(F3);

accelStatex = analogRead(AX);

accelStatey = analogRead(AY);

int mappedF3 = map(accelStatex,600,200,60,127);

int XmappedF3 = map(accelStatey,600,200,60,127);

if (flex3 < flexState3) {

if (flex3 < 395) {

SendMidi (0x90, mappedF3 +2, 120);




SendMidi (0x80, mappedF3 +2, 120);



flex4 = analogRead(F4);

accelStatex = analogRead(AX);

accelStatey = analogRead(AY);

int mappedF4 = map(accelStatex,600,200,60,127);

int XmappedF4 = map(accelStatey,600,200,60,127);

if (flex4 < flexState4) {

if (flex4 < 395) {

SendMidi (0x90, mappedF4 +3, 120);




SendMidi (0x80, mappedF4 +3, 120);



// delay(5);

flexState1 = flex1;

flexState2 = flex2;

flexState3 = flex3;

flexState4 = flex4;

accelStatex = accelx;

accelStatey = accely;


void SendMidi (int cmd, int value, int vel) {

Serial.write (cmd);

Serial.write (value);

Serial.write (vel);


Once i had established the Note-On and Note-Off commands i now need to understad the MIDI note values.  Below is a link to a webpage that has the details of all MIDI note numbers that helped with this.

As i was developing the program it became aparent that i would need to undersatand some basics about the MIDI Protocol, the code that would be needed to send the apropriate Note-On and Note-Off commands.  Below is a link to a web page that helped me with the basics, however the protocols i required were Note-On (0x90) and Note-off (0x80)

Now that it is possible for Ableton Live to detect my interface as a MIDI Input i could begin to write the program for the Arduino Programming environment that would convert the voltage data into MIDI data.  The following webpages gave me some ideas that i developed and built on.

In one of my previous posts i mentioned that i could not get my Digital Workstation to recognise my interface as a MIDI Input.  This turned out to be the fact that my Lap-top does not like having both the Arduino’s and the MIDI’s USB cable connected at the same time.  This lead to the need for an external power supply.

After consideration it was decided that a 9v battery would be used, this meant the addition of a power supply and a rocker switch to isolate the battery.  With this addition it was now possible to identify my interface as a MIDI Input.


Its been a while since my last post so i’ve got a lot of info to update.

The last post outlined my attempts to transfer data from my glove to a Digital Workstation.  Since then i have had a great deal of success and now have a working interface.

Previuosly i had been thinking about either using MaxMSP or using the Arduino Programming environment to convert voltage data into MIDI data.  After a great deal of experimentation and a fair deal of help from my fellow students i have now chosen to use the Arduino to convert the data before sending this to Ableton Live.

This week i have been considering the way in which i will use the voltage signal output from the glove to control a Digital Workstation.  The two possible ways this can be achieved would be

1. To use Max to output MIDI data which in turn would be used as a MIDI Input data by either Protools or Ableton.  I understand this is a relatively straight-forward process however i have not yet been able to get either workstation to locate Max as a MIDI input. I have use the following website in an attempt to fix this but no joy so far and will need to speak with my lecturer for further advice.

2. To program the Arduino to convert the serial data into MIDI data as an Output which could be used by either workstation as a MIDI Input.  To try this out i have bought a MIDI – USB converter and a MIDI Jack at a combined cost of £27 from Maplins.  I have also downloaded a free MIDI Monitor from the website below. Using the following websites i have attempted to do this but, as before, i am still yet unable to get either workstation to locate the USB as a MIDI Input. – MIDI Monitor

MIDI Monitor – screen shot

USB – MIDI Connector       MIDI Jack


Using a Multi meter i have now tested the the output voltage of all the components and the results are as follows –

Flex Sensors – 2.1 – 1.1v

Accelerometer X and Y – 2.3 – 1.8v

Having checked the following website and with my lecturer we are both in agreement that these levels should be fine for my needs as i intend to use the USB of a computer to power the Arduino.  Had i wanted to use this as a remote object i would have to consider signal conditioning as i would have required an external power supply such as a 9v battery.

Ok, time for my weekly update.

Using a hot glue gun i have now secured the accelerometer to the vera board sewen to the back of the glove.  With all the sensors now secured it was time to consider how i was going to get the signal from the glove to the Adruino and then into the computer.

I had previously used a meduim sized black plastic housing straped to the forearm containing the circuit and the arduino but felt this was too bulky and looked for an alternative aproach.

I decided that i would use a smaller plastic housing, still strapped to the forearm, as a means of connecting the multi-core connecting wires i used for the sensors to a long piece of ribbon cable that would then be connected to the the larger plastic housing containing the circuit and the arduino.  Below is a picture of how this will look.

Below is a picture showing the connections inside the small housing.  The vera board will eventually be glued to the plastic box itself and the cables will have a cable ties attached inside the box to reduce pull on the soldering.

next was to attach the velco strap to the housing to support this on the forearm.

the following picture shows the larger box with the arduino inside, this will also hold the circuit i will build for the vlotage divider resistors for the flex sensors and the capasitors for the accelerometer X and Y. (in the picture i have used a mini bread board to represent this)