Main Menu

Secondary Menu

Violano-Lilypad Arduino XBee Instrument

Introduction: Violano-Lilypad Arduino XBee Instrument

This product is an instrument that synchronizes motion with art and music. By controlling the amount of light that falls on the sensor, one can control the splash of colors being made on the screen along with the music note the instrument generates. This was developed by Jooeun and Noora to mark our right of passage to being Makers.

This product is an attempt to recreate the notion of making the invisible visible through detailed design. The product is inspired by the underlying premise of the paper "making the invisible visible in science museums through augmented reality devices (Yoon & Wang, 2014)"; where by attaching dynamic visualization of magnetic field to the manipulation of real bar magnets, they found visitors to be more engaged as it made provision for difficult concepts to be accessible through visualization.

We tried to emulate this by developing a product that provides visualization in the form of splashing of paint, to represent the degree to which the light was being manipulated by the motion detected by the sensor. This has been developed for kids and adults alike to provide them with a "first person encounter"; a on notion on which museums operate. First person encounter is the degree to which a product can catch and maintain an individual's attention. The underlying premise is by providing an effective first person encounter, one can prompt the individual to build and pursue the curiosity that emerges as a result of such encounters. The complexity of the product varies on the makers prior knowledge with programming.

Step 1: Get Materials

In order to develop this product, you will need:

1) Lilypad Board X 1

2) Lilypad XBee X 1

3) Lilypad LED X 4

4) Lilypad Light Sensor X 1

5) Lilypad Buzzer X 1

6) Conductive thread and Needle X 1

7) Batter and Lilypad Power Supply X 1

8) USB Cable X 1

9) Alligator clips wire X many

10) Fabric X as much as you want

To program, you will also need:

1) Arduino (arduion.cc)

2) Processing(processing.org)

3) X-CTU (http://www.digi.com/support/productdetail?pid=3352)

For Windows user, it is suggested to download ver.5.2.8.6 installer

Step 2: Connecting Lillypad With LED and Sensor

a. It is advisable to stop and check at every step of programming before proceeding on to the attaching the LEDs.

b. Start by checking if the sensor works by attaching Led with the Lillypad board using alligator clips.

c. Use the circuit pathway illustrated in the attachment to connect the LEDs to the sensor.

1. Blink LEDs with light sensor-1 (the result has been recorded below)

Program the light sensor to receive the specified amount of light using the below mentioned code. This will determine when the LED would turn on.

int myLed[] = {A2, A3, A4};

int i = 0;

int sensor = A5;

void setup() {

Serial.begin(9600);

for (i = 0; i < 3; i++) {

pinMode(myLed[i], OUTPUT);

}

}

void loop() {

int sensorValue = analogRead(sensor);

Serial.println(sensorValue);

delay(100);

if (sensorValue > 225) {{

digitalWrite(myLed[i], LOW);

}

}

else {

light();

}

}

void light() {

for (i = 0; i < 3; i++) {

digitalWrite(myLed[i], HIGH);

delay(100);

digitalWrite(myLed[i], LOW);

delay(100);

}

}

2. Control LEDs with light sensor - 2

The objective is to control the LED separately with the light sensor.

As you check the functioning of light sensor through the serial port, make note of the maximum and minimum value. You can use this to program to determine the manipulation of the light sensor. For instance, to what degree should the light sensor be covered from light for the LED to turn on.

int myLed[] = {A2, A3, A4};

int i = 0;

int sensor = A5;

void setup() {

Serial.begin(9600);

for (i = 0; i < 3; i++) {

pinMode(myLed[i], OUTPUT);

}

}

void loop() {

int sensorValue = analogRead(sensor);

Serial.println(sensorValue);

delay(100);

if (sensorValue < 50) { // Tur all the LED off, if the value is higher than 40

digitalWrite(myLed[i], LOW);

}

else if (sensorValue > 60, sensorValue <120){

digitalWrite(myLed[0], HIGH);

delay(100);

digitalWrite(myLed[0], LOW);

delay(100);

}

else if (sensorValue > 120, sensorValue <230){

digitalWrite(myLed[1], HIGH);

delay(100);

digitalWrite(myLed[1], LOW);

delay(100);

}

else if (sensorValue > 230, sensorValue <330){

digitalWrite(myLed[2], HIGH);

delay(100);

digitalWrite(myLed[2], LOW);

delay(100);

}

else

{

light();

}

}

void light() {

for (i = 0; i < 3; i++) {

//digitalWrite(myLed[i], HIGH);

//delay(100);

digitalWrite(myLed[i], LOW);

delay(100);

}

}

Step 3: Add Buzzer

Finally move to the see if the LED and sensor works with the buzzer.Program the buzzer to be controlled by the amount of light that falls on the sensor. Program the buzzer to correspond to the playing of a note when the specified amount of light falls on the sensor.

Refer to the curicut illustrated to add the sensor.

The Arduino code used is attached below:

int myLed[] = {A2, A3, A4}; int sound[] = {523, 539, 587}; // C,D,E

int lightScope[]={360,370,380,400};

int i = 0;

int sensor = A6;

int sPin = 9;

byte val; //save variable

int buzzerPin = 9;

void setup() {

Serial.begin(9600);

for (i = 0; i < 3; i++) {

pinMode(myLed[i], OUTPUT);

}

}

void loop() {

int sensorValue = analogRead(sensor);

Serial.println(sensorValue);

delay(100);

if (sensorValue < 20) { // Tur all the LED off, if the value is higher than 40

digitalWrite(myLed[i], LOW);

}

else if (sensorValue > lightScope[0], sensorValue < lightScope[1] ) {

lightPin(myLed[0], 100);

tone(buzzerPin, 523, 1000);

delay(100);

}

else if (sensorValue > lightScope[1], sensorValue < lightScope[2]) {

lightPin(myLed[1], 100);

tone(buzzerPin, 587, 1000);

delay(100);

}

else if (sensorValue > lightScope[2], sensorValue < lightScope[3]) {

lightPin(myLed[2], 100);

tone(buzzerPin, 659, 1000);

delay(100);

}

else

{

light();

}

}

void light() {

for (i = 0; i < 3; i++) {

digitalWrite(myLed[i], LOW);

delay(100);

}

}

void lightPin(int ledPin, int ledDelay) {

digitalWrite(ledPin, HIGH);

delay(ledDelay);

digitalWrite(ledPin, LOW);

delay(ledDelay);

}

Step 4: Connect Lilypad With Processing

Before moving forward to wireless part, it is necessary to connect Arduino with Processing. The processing code is provided towards the end of this section. Follow the steps below to make Arduino communicate with Processing.

[Testing]

Start with initial testing by sending numbers from Arduino to Processing.

1. [Arduino] send ASCII 0~255 to serial.

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

}

byte i;

void loop() {

Serial.write(i++);

delay(500);

}

2. Open the serial monitor and check if the numbers are appearing on the serial port monitor. Make sure you close the serial monitor. It is very important to close the serial monitor post the number check to ensure that errors don't pop up.

3. [Processing] Receive this number form Processing and display on the console.

import processing.serial.*;Serial myPort;

int val;

void setup(){

size(200, 200);

String portName = Serial.list()[2];

myPort = new Serial(this, portName, 9600); }

void draw(){

if (myPort.available() > 0) {

val = myPort.read();

println(val);

}}

a. It is important to identify the port number for Processing so start by checking the port number.

b. You'll receive error when the port number is incorrect. Use Processing code bellow to check your port number.

d. Also, make sure you closed serial monitor. It operates one at a time.

When you receive the number from Processing, it's time for you to add code.

Intended result:

The code below is a remixed Processing code which interactively draws a paint varying with the light value Processing receives. In order to control drawing with the light sensor, there should be certain amount of light. If there is too much or too less light it will not work.