12-12-2011@ HKU school for arts, Utrecht

I’ve always wanted to combine dance and light with my work in electronics and music. So I made a light sensitive wireless suit wich translates the light intensity from various parts on the body into raw midi data. Big thanks to Charlie Duran for dancing his socks off!

Technical stuff:
It works by reading 10 strategically placed light sensitive resistors wich are read by a arduino mega. The mega then transmits this data over a wireless link to another arduino(teensy 2.0) wich translates the data into midi cc messages and sends them over usb directly into ableton live. There is no editing afterwards and all the control changes are coming directly from the suit.

For the wireless link Im using the nRF24l01 by nordic semiconductor, a cheap and powerfull 2.4 ghz radio transmitter/reciever.

The code consist of bits and pieces hacked together but it works very well and there is almost zero latency. Please send me an email if you’ve found the code usefull, Im always interested to see what others might use it for.
/*
Light to midi suit arduino MEGA transmitter
Copyright Jochem van Grieken 12-2011
jochemvangrieken@gmail.com
jochemvangrieken.wordpress.com

uses the RF24 library:

http://maniacbug.github.com/RF24/index.html

Light Dependent Resistors set up as voltage dividers with a
20k resistor to ground on pins A6 to A15.
Nrf24l01 pins:
Vcc - 3.3V
CE - 8
CSN - 9
SCK - 52
MOSI - 51
MISO - 50
IRQ - not connected

*/

#include
#include "nRF24L01.h"
#include "RF24.h"

#define inputs 10
#define e 1

int currentLDR [10] = {0,0,0,0,0,0,0,0,0,0};
int LDR [10] = {0,0,0,0,0,0,0,0,0,0};
int LDRsend [10] = {0,0,0,0,0,0,0,0,0,0};

RF24 radio(48,49);

//open radio pipe to communicate

const uint64_t pipe = 0xE8E8F0F0E1LL;

void setup()
{
//set up radio

radio.begin();

radio.openWritingPipe(pipe);

//print the radio configuration

radio.printDetails();

}
void loop(){
for(int i=0; i e) {
LDRsend[i] = currentLDR[i];
LDR[i] = currentLDR[i];
}
}

{
radio.write( LDRsend, sizeof(LDRsend));

}
}

/*
Light to midi suit Teensy 2.0 reciever
Copyright Jochem van Grieken 12-2011
jochemvangrieken@gmail.com
jochemvangrieken.wordpress.com

uses the RF24 library:

http://maniacbug.github.com/RF24/index.html

Teensy 2.0
nRF24L01 pins:
CE - 8
CSN - 9
SCK - 1
MOSI - 2
MISO - 3
IRQ - not connected
*/

#include
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

RF24 radio(8,9);

//open radio pipe to communicate

const uint64_t pipe = 0xE8E8F0F0E1LL;

// Smoothing amount
const int numReadings = 30;

// Set the readings from the sensorreadings to 0
int readings[numReadings] = {0,0,0,0,0,0,0,0,0};

// The number of sensors
int sensors = 10;

// The index of the current reading
int index = 0;

// Running total
int total = 0;

// Pin total
int pintotal[10] = {0,0,0,0,0,0,0,0,0};

// Pin average
int average[10] = {0,0,0,0,0,0,0,0,0};

// Set midi channel to send to 1
int channel = 1;

// Set the last readings to 0
int lastreading[10] = {0,0,0,0,0,0,0,0,0};

// Array for recieving the sensorreadings
int sensorRecieved[10];

void setup()
{
Serial.begin(31250);

// setup the reciever
radio.begin();

radio.openReadingPipe(1,pipe);

radio.startListening();
}

void loop()
{
// if there is data ready
if ( radio.available() )
{
// Dump the payloads until we've gotten everything
bool done = false;
while (!done)
{
// Fetch the payload, and see if this was the last one.
done = radio.read( sensorRecieved, sizeof(sensorRecieved) );
}
}
// Get the sensorreadings
for (int i = 0; i < sensors; i++ ) {

// Set index to zero
index = 0;

// Loop to create average reading
for (int j = 0; j < numReadings; j++ ){
// Subtract the last reading
total = total - readings[index];
// Read from the sensor
readings[index] = sensorRecieved[i];
// Add the reading to the total
total = total + readings[index];
// Advance to the next position in the array
index = index++;
pintotal[i] = total;
}

// Calculate the average

average[i] = (pintotal[i]/numReadings)/8;

// If reading is different from the previous
if (lastreading[i] != average[i]){

// Send midi data
usbMIDI.sendControlChange(i+1, average[i], channel);
}
// Set last array value to current value
lastreading[i] = average[i];
}
// Delay output by 5ms
delay(5);
}