The One Man Show

Description

In our endeavour to make a sonorous musical instrument, we wanted to explore the sounds different materials make on being impinged. We started with a lamp screen and brainstormed ideas around what role it could play in an interactive musical instrument. Someone suggested that it could represent a caricature of a one man band, replete with arms and legs. It sounded like a great idea and we we forged ahead with it.

We are using 4 Arduinos to control 4 Servo motors. Two of the motors are responsible for controlling the rattle and the maraca, which manifest themselves in the form of arms. The third motor controls the bobbing head, while the fourth one is responsible for impinging the tin lamp screen from the inside.

Materials used

  • Balloon
  • Cardboard
  • 4 Arduinos
  • 4 Breadboards
  • Wires
  • Pipe cleaners
  • Popsicle sticks
  • Masking tape
  • Lamp screen
  • Thread

/*
* Servo with Potentiometer control
* Theory and Practice of Tangible User Interfaces
* Nisha, Elena and Mudit are using the same code
*/

int servoPin = 7; // Control pin for servo motor
int potPin = 0; // select the input pin for the potentiometer

int pulseWidth = 0; // Amount to pulse the servo
long lastPulse = 0; // the time in millisecs of the last pulse
int refreshTime = 20; // the time in millisecs needed in between pulses
int val; // variable used to store data from potentiometer

int minPulse = 500; // minimum pulse width

void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pulseWidth = minPulse; // Set the motor position to the minimum
Serial.begin(9600); // connect to the serial port
Serial.println("servo_serial_better ready");
}

void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024

if (val > 0 && val <= 999 ) { pulseWidth = val*2 + minPulse; // convert angle to microseconds Serial.print("moving servo to "); Serial.println(pulseWidth,DEC); } updateServo(); // update servo position } // called every loop(). void updateServo() { // pulse the servo again if the refresh time (20 ms) has passed: if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulseWidth); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
lastPulse = millis(); // save the time of the last pulse
}
}

Sam's code

int servoPin = 7; // Control pin for servo motor
int lightSensorPin = 0; // input for light sensor

int pulseWidth = 0; // Amount to pulse the servo
long lastPulse = 0; // the time in millisecs of the last pulse
int refreshTime = 20; // the time in millisecs needed in between pulses
int val; // variable used to store data from serial port
long lastUpdate = 0; // last update of ring

int minPulse = 500; // minimum pulse width
int maxPulse = 2250; // maximum pulse width
int lightLimit; // calibrated limit for light

void setup() {
pinMode(servoPin, OUTPUT); // Set servo pin as an output pin
pulseWidth = 1156; // Set the motor position to the minimum
Serial.begin(9600); // connect to the serial port
Serial.println("Servo control program ready");
val = analogRead(lightSensorPin);
lightLimit = val - 100; // calibrated light
}

void loop() {
val = analogRead(lightSensorPin); // read the value from the sensor, between 0 - 1024
//Serial.println(val);
// Ring bell
if (val < lightLimit) {
pulseWidth = 1400;
lastUpdate = millis();
while (millis() - lastUpdate <= 200) { updateServo(); } pulseWidth = 1156; } updateServo(); // update servo position } // called every loop(). // uses global variables servoPi, pulsewidth, lastPulse, & refreshTime void updateServo() { // pulse the servo again if rhe refresh time (20 ms) have passed: if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH); // Turn the motor on
delayMicroseconds(pulseWidth); // Length of the pulse sets the motor position
digitalWrite(servoPin, LOW); // Turn the motor off
lastPulse = millis(); // save the time of the last pulse
}
}

Video: https://drive.google.com/a/berkeley.edu/file/d/0B7JCq5np49-7S1hZRVIzOVJjLXc/view?usp=sharing

 

img_20161107_134025

 

Leave a Reply