Group Members: Shreyas, Noriko, Olivia, Shana, Christopher Fan
Description:
The goal of the assignment was to create a musical instrument mapping more than four separate types of user input to generate sounds.
Our group chose to emphasize a type of drum circle emphasizing different types of percussive sounds using different materials between the moving object “stick” and the receiving object “drum”. We added main melody by Piezo and tried to synthesize the sounds.
The group also explored creating musical instruments based on `Jal Tarang` a traditional Indian musical instrument where music is created by hitting glass tumblers (refer: http://www.youtube.com/watch?v=x_3iSuoyfi8). So, we created a ‘stick-hitter’ attached to a servo motor to repeatedly be able to hit the water containers. Initially wood as a material was used but the sound produced was muffled, so it was replaced by a steel hitter. Then, different kinds of tumblers (glass, steel, paper) were lined up to ascertain the kind of sound they produced. Finally glass tumbler was chosen as it had the most melodious of songs.
Finally, to be able to create different sounds sequentially, we needed to be able to move the servo motor in a uniform manner (because it was observed that, hitting the same containers at different heights also produces different sounds, hence uniformity was needed). So, the servo motor was mounted on a flat plane which could be slid horizontally on a plane surface by the instrument player.
Sounds Generated:
1) Spinning: Attaching string and metal balls to servo motor. Metal balls hit glasses and generate tinkling sounds. It takes on-off input from force sensor.
2) Tapping: Using a piece of balsa wood for the stick oscillating between two types of glass objects placed in a left and right position. The poteniometer controls the position of the stick which moves in a 180 degree arc due to a servo motor.
3) Circular Gong:
4) Twinkle melody: Piezo generates melody of “Twinkle” triggered by potentiometer input.
5) ‘Ting’ - the sound by steel hitting a glass tumbler with or without water
Materials:
1) Spinning: 1 Arduino (shared with Piezo), servo motor, force sensor, two wine glasses, wood parts/screws
2) Tapping: 1 Arduino, servo motor, potentiometer, two glass bottles, screws/wood
3) Circular Gong:servo motor, metal plate, metal rod, screws/balsa wood
4) Twinkle Melody: 1 Arduino (shared with Spinning), Piezo, potentiometer
5) ‘Ting’: servo motor, metal clip, screws, tape, flat board, glass tumbler
Video:
http://www.youtube.com/watch?v=F4k-lUsx2oU
http://www.youtube.com/watch?v=dR7kuf4kHOY
http://youtu.be/IGUPBkzsfIY (Jal Tarang)
Code:
Code for Gong and Tapping
#include <Servo.h>
Servo myservo; // create servo object to control a servo for gong
Servo myservo2; // create servo object to control a servo for tapping
int potpin = 0; // analog pin used to connect the potentiometer
int potpin2 = 1; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int val2; // variable to read the value from the analog pin
void setup()
{
myservo.attach(7); // attaches the servo on pin 9 to the servo object
myservo2.attach(5); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(5); // waits for the servo to get there
val2 = analogRead(potpin2); // reads the value of the potentiometer (value between 0 and 1023)
val2 = map(val2, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo2.write(val2); // sets the servo position according to the scaled value
delay(5); // waits for the servo to get there
}
Code for spinning and Twinkle melody
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int valPot = 0; //takes value from potentiometer input
int potPin = 1; //attaches potentiometer to pin1
int speakerPin = 8; //attaches Piezo to pin8
int length = 42; //sets length of notes
char notes[] = "ccggaagffeeddcggffeedggffeedccggaagffeeddc"; //melody notes
int beats[] = { 1, 1, 1, 1,1,1,2, 1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,3};
int tempo = 240; //controll tempo of Piezo
int valSens = 0; //takes value from force sensor input
int sensorPin = 0; //attaches force sensor to pin0
int pos = 0; // variable to store the servo position
void setup()
{
myservo.attach(7); // attaches the servo on pin 7 to the servo object
Serial.begin(9600);
pinMode(speakerPin, OUTPUT); //sets Piezo as output
Serial.println("ready");
}
void loop()
{
valSens= analogRead(sensorPin); //reads input from force sensor
valPot = analogRead(potPin); //reads input from potentiometer
Serial.println(valSens);
if (valPot>0){ //play melody from Piezo
play();
delay(10);
}
if (valSens>800){ //spin the servo and generate tinkling sounds
sweep();
}
}
void sweep(){ //controlls servo motion
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'
delay(1); // waits 1ms for the servo to reach the position
}
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(1); // waits 1ms for the servo to reach the position
}
}
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tone);
}
}
void playNote(char note, int duration) {
char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };
// play the tone corresponding to the note name
for (int i = 0; i < 23; i++) {
if (names[i] == note) {
playTone(tones[i], duration);
}
}
}
void play(){
for (int i = 0; i < length; i++) {
valPot = analogRead(potPin);
Serial.println(valPot);
if (notes[i] == ' ') {
delay(beats[i] * tempo); // rest
}
else {
if (valPot>100){
playNote(notes[i], beats[i] * tempo);
}
}
// pause between notes
delay(tempo / 2);
}
}
## Ting (Jal Tarang)
---------------------------
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 20; // variable to store the servo position
void setup()
{
myservo.attach(7); // attaches the servo on pin 7 to the servo object
}
void loop()
{
for(pos = 40; pos < 140; 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'
delay(5); // waits 15ms for the servo to reach the position
}
for(pos = 40; pos>=140; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
}
- Login to post comments