After a two month experimentation with the LilyPad Arduino microprocessor, some conductive thread, a buzzer and a light sensor, I constructed this interactive embroidery inspired by the LilyPad itself and the MicroKorg synthesizer, hence the name LilyKorg.

The embroidery is made with muline thread and the electronic parts include the LilyPad Arduino simple board, an RGB LED, a light sensor, a buzzer and of course conductive thread!

I was using the RolandPad and the LilyKorg embroideries as part of the performance of the Athenian based band Conductive and now they form part of the Lilytronica performance series.

You can check out some more of my early experiments here

This is the source code:
/* Lilykorg: an interactive embroidery
by Afroditi Psarra
December 2011*/

#include "pitches.h" //include public constants NOTES

//declare variables

// main melody from Kraftwerk's "Transeurope Express"
int melody[] = {
NOTE_G3, NOTE_GS3, NOTE_CS4, NOTE_C4, 0, 0, NOTE_G3, NOTE_GS3, NOTE_C4, NOTE_AS3, 0, NOTE_G3, NOTE_GS3, NOTE_CS4, NOTE_C4, 0, NOTE_AS3, NOTE_C4, 0};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
2, 2, 4, 2, 8, 8, 4, 2, 4, 1, 4, 2, 2, 4, 2, 32, 4, 1, 1 };

int percussiveNote[] = {
NOTE_DS3, NOTE_DS3 };

int percussiveDurations[] = {
8, 8 };

//RGB LED
int redPin = 11; //Red LED connected to digital pin 11
int bluePin = 10; //Blue LED connected to digital pin 10
int greenPin = 9; //Green LED connected to digital pin 9

int speakerPin = 5; //buzzer connected to digital pin 5

int sensorPressA = 19; //conductive thread used as one pressure sensor connected to analog pin a5, 19
int sensorPressB = 18; //conductive thread used as another pressure sensor connected to analog pin a4
int sensorLight = 16; //light sensor connected to analog pin a2

int sensorPressAValue; //variable to store the value coming from first pressuse sensor
int sensorPressBValue; //variable to store the value coming from second pressure sensor
int sensorLightValue; //variable to store the value coming from the light sensor

int a = 10;
int b = 100;
int t = 0; // timer
int f = 0;
int LIGHT_STEP = 500; //constant
int LIGHT_OFFSET = 2000; //constant

void setup()
{
Serial.begin(9600); //initialize the serial port
pinMode(redPin, OUTPUT); //sets the redTab to be an output
pinMode(bluePin, OUTPUT); //sets the blueTab to be an output
pinMode(greenPin, OUTPUT); //sets the greenTab to be an output
pinMode(speakerPin, OUTPUT); //sets the buzzer to be an output
digitalWrite(16, HIGH); //sets analog pin a2 to high
digitalWrite(18, HIGH); //sets analog pin a4 to high
digitalWrite(19, HIGH); //sets analog pin a5 to high

}

void loop() {

sensorPressAValue = analogRead(sensorPressA); // read the value from the sensor
Serial.println(sensorPressAValue); // send that value to the computer
if (sensorPressAValue == 1016) {
color(0, 0, random(255)); //white
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 3; thisNote++) {

// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int percussiveDuration = 1000/percussiveDurations[thisNote];
//tone function uses pin5 as an output and reproduces the matrix of notes and durations
tone(speakerPin, percussiveNote[thisNote],percussiveDuration);

// to distinguish the notes, set a minimum time between them.
// the note's duration
int pauseBetweenNotes = percussiveDuration * 1.10;
delay(pauseBetweenNotes);
}

}

sensorPressBValue = analogRead(sensorPressB); //read the value from the sensor
Serial.println(sensorPressBValue); //send that value to the computer
if (sensorPressBValue >= 1023) {
color(255, 0, 0); //red
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 19; thisNote++) {

color (random(255), random(125), 0); //random warm color

// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000/noteDurations[thisNote];
//tone function uses pin5 as an output and reproduces the matrix of notes and durations
tone(speakerPin, melody[thisNote],noteDuration);

// to distinguish the notes, set a minimum time between them.
// the note's duration
int pauseBetweenNotes = noteDuration * 1.10;
delay(pauseBetweenNotes);
}
}

sensorLightValue = analogRead(sensorLight);//read the value from the sensor
Serial.println(sensorLightValue);//send that value to the computer
beep(speakerPin, sensorLightValue *LIGHT_STEP + LIGHT_OFFSET + f, a);
if (sensorLightValue < 40) {
t = 0;
a = 5;
f = 0;
color(random(255), 0, 0); //random warm color
}

else if (sensorLightValue > 50) {
t++;
}

else if (t > 200 && t <= 1000) {
a = 20;
f = f + 10;
color(0, random(255), random(255)); //random cold color
}

}

void beep(unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds) //the sound producing function
{
int x;
long delayAmount = (long)(1000000/frequencyInHertz);
long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
for (x=0;x {
digitalWrite(speakerPin,HIGH);
delayMicroseconds(delayAmount);
digitalWrite(speakerPin,LOW);
delayMicroseconds(delayAmount);
}
}

void color (unsigned char red, unsigned char green, unsigned char blue) { //the color generating function

analogWrite(redPin, 255-red);
analogWrite(bluePin, 255-blue);
analogWrite(greenPin, 255-green);
}

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.