Create an automated sound installation
We created a shaker sound reminiscent of a cocktail bar.
The sounds of a bartender’s shaker and ice cube are represented by a combination of cans and dice.
The sound of the servo motor is noticeable, which is a bit disappointing so I also tried layering different music over the sound of the servo motor.
Process
The following photographs show the process of making it, using an Arduino and a servo motor. The can containing the dice is fixed with a servo motor.
The code for the servomotor is written below using the knob example file from Arduino.
/*
Controlling a servo position using a potentiometer (variable resistor)
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
modified on 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Knob
*/
#include <Servo.h>
Servo myservo; // create Servo object to control a servo
int potpin = A0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int sensorValue = 0;
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the Servo object
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(potpin);
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 210); // scale it for use with the servo (value between 0 and 180)
// myservo.write(val);
myservo.write(210);
delay(1000);
myservo.write(0);
Serial.print("sensor = ");
Serial.println(sensorValue);
Serial.println();
Serial.print("motor value = ");
Serial.println(val);
delay(1000); // waits for the servo to get there
}