Team Members: Cesar, Stuart, Shaun, Suhaib, Erica & Priya
In this assignment, we decided to create an orchestra using several musical instruments created by different members on the team. We decided to use two foot sensors as our input that wirelessly transmit the values to all our musical instruments through XBee. We came up with 3 different musical instruments that play whenever they receive input from the sensors. Cesar took the responsibility of input and wireless transmission using XBee and made sure all our instruments were receiving the input. Attaching the individual code and video for each of our musical instruments below:
Stuart:
Description:
Two "stringed" instruments were constructed using rubber bands and hollow containers (cup and yogurt container respectively). The rubber bands were stretched over the openings of the containers at different tensions to produce a different tone when each is plucked. A servo motor was used to achieve the plucking action, and this is controlled wirelessly through an xBee bluetooth adapter. Acrylic was laser-cut in circular geometries to provide structural support to the instruments as a whole.
Components:
Arduino Uno
2 rubber bands
tape
xBee bluetooth adapter
acrylic
yogurt container
paper cup
2 servo motors
jumper wires
Code:
Plastic Yogurt Container Code:
#include <SoftwareSerial.h>
SoftwareSerial xbee(2, 3); // RX, TX
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
Serial.begin(9600);
Serial.println( "Arduino started receiving bytes via XBee" );
// Set the data rate for the SoftwareSerial port.
xbee.begin(9600);
myservo.attach(10); // attaches the servo on pin 10 to the servo object
}
float lastReceivedValue = 0;
int index = 0;
char temp;
char message[6];
boolean recordMessage = false;
void receiveMessage(char header){
if (xbee.available() > 0) {
temp = (char) xbee.read();
// Serial.println(temp);
if(temp == header) {
recordMessage = true;
index = 0;
}
else{ return; }
while(recordMessage){
temp = (char) xbee.read();
message[index] = (char)temp;
index ++;
// if end
if(index > 4 || (char)temp == '\n'){
message[5] = '\0';
lastReceivedValue = atof(message);
recordMessage = false;
}
}
Serial.println(message);
}
}
void loop() {
receiveMessage('S');
Serial.println(lastReceivedValue);
int v1 = lastReceivedValue * 500;
for(pos = 30; pos < 95; pos += 5) // goes from 30 degrees to 80 degrees
{ // in steps of 5 degrees (change to increase speed - but limited by max spped of motor)
myservo.write(pos); // tell servo to go to position in variable 'pos'
}
delay(1000 -v1); // delay time after fist pluck (in ms)
for(pos = 95; pos>=30; pos-=5) // goes from 80 degrees to 30 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
}
delay(1000 -v1); //dealy time after the shaft returns to origninal location (in ms)
}
Yogurt Container Code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 60; pos < 110; pos += 5) // goes from 30 degrees to 80 degrees
{ // in steps of 5 degrees (change to increase speed - but limited by max spped of motor)
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
delay(500); // delay time after fist pluck (in ms)
for(pos = 110; pos>=60; pos-=5) // goes from 80 degrees to 30 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
delay(500); //dealy time after the shaft returns to origninal location (in ms)
}
Shaun & Suhaib:
Description:
We tried to simulate the unstructured nature of wind chimes with physical input (pressure).
The sounds are subtle and the amount of disruption is directly proportional to the pressure you apply.
Materials used:
1 10K resistor
2 Coca Cola cans
Erektor set
4 Magnets
1 Arduino
1 FSR
wires
Arduino Code:
/*
* I262 - Synthesis 1
* ---------------------------
* Function : FSR to control servo motor fluctuations/angles of displacement
* Date : 11.19.2013
* Author : Suhaib Saqib Syed/Shaun Guidici
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
int sensorPin = 2; // select the input pin for the FSR sensor
int val = 0;
void setup()
{
myservo.attach(6); // attaches the servo on pin 6 to the servo object
Serial.begin(9600); // to monitor FSR output
}
void loop()
{
val = analogRead(sensorPin); // read the value from the sensor, 0-1023
Serial.println(val); // writing the value to the PC via serial connection
for(pos = 0; pos < val/8; pos += 1) // goes from 0 degrees to angle proportional to FSR value
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(1); //waits 1ms for the servo to reach the position
}
delay(5); //wait for some time before going back
for(pos = 10; pos>=0; pos-=1) //jumps to 10 degrees to 0 degrees
{
myservo.write(pos); //tell servo to go to position in variable 'pos'
delay(1); //waits 15ms for the servo to reach the position
}
delay(500); //wait for some time before going back
}
Priya:
Description: I made bass drums using servo motors that change the beats according to the input received from the sensors.
Code:
#include <SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial xbee(2, 3); // RX, TX
Servo myservo;
int pos=0;
int servoPin = 12; // Control pin for servo motor
int delVal=1;
int delVal2=1;
int interval=5;
int potval=0;
void setup()
{
myservo.attach(12);
Serial.begin(9600);
Serial.println( "Arduino started receiving bytes via XBee" );
// Set the data rate for the SoftwareSerial port.
xbee.begin(9600);
}
float lastReceivedValue = 0;
int index = 0;
char temp;
char message[6];
boolean recordMessage = false;
void receiveMessage(char header){
if (xbee.available() > 0) {
temp = (char) xbee.read();
// Serial.println(temp);
if(temp == header) {
recordMessage = true;
index = 0;
}
else{ return; }
while(recordMessage){
temp = (char) xbee.read();
message[index] = (char)temp;
index ++;
// if end
if(index > 4 || (char)temp == '\n'){
message[5] = '\0';
lastReceivedValue = atof(message);
recordMessage = false;
}
}
Serial.println(message);
}
}
void loop() {
receiveMessage('S');
Serial.println(lastReceivedValue);
potval=lastReceivedValue*500;
// if(potval<10){
// interval=500;
// }
// else if(potval<40){
// interval=1000;
// }
// else if(potval<65){
// interval=500;
// }
// else{
// interval=100;
// }
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
// waits 15ms for the servo to reach the position
}
delay(1000-potval);
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
}
delay(1000 - potval);
}
Videos:
1. https://vimeo.com/79863012
2. https://www.youtube.com/watch?v=7vML-GurHbs&feature=youtu.be
3. https://www.youtube.com/watch?v=h1NTBJD9bI4&feature=youtu.bea
- Login to post comments