Description
For the homework assignment in this lab, I made a stress reliever "Stress Bubble." In order to achieve input output coincidence, I used the force sensor (FSR), three LEDs and the piezo speaker. The Stress Bubble was formed by using bubble wrap and a plastic shopping bag diffuser to encapsulate the FSR and LEDs. The piezo speaker is located externally to this setup. When increasing force is applied to the Stress Bubble, the bubble reacts by changing colors (from green to blue to red with increasing force), and the piezo speaker changes its tone as well. As the force applied to the Stress Ball increases, the pitch of the piezo speaker also increases. The result is a rather satisfying experience that relieves stress. The color change of the bubble and pitch of the speaker work well to de-stress the user.
Components
1- Arduino Uno Microcontroller
1- Breadboard
1- 10KΩ Resistor
3- Light Emitting Diodes (LEDs) (Red, Green, Blue)
1- USB Cable
1- Apple Laptop Computer (Mac OSX)
1- Force Sensitive Resistor (FSR)
1 - Piezoelectric Speaker
Code
void setup() {
// initialize the serial communication:
Serial.begin(9600);
}
void loop() {
Serial.begin(9600);
int bluepin = 13;
int greenpin = 12;
int redpin = 11;
int speaker = 8;
int val = analogRead(0);
pinMode(bluepin, OUTPUT);
pinMode(greenpin, OUTPUT);
pinMode(redpin, OUTPUT);
pinMode(speaker, OUTPUT);
// send the value of analog input 0:
int sensorReading = analogRead(A0);
Serial.println(sensorReading);
Serial.write(sensorReading);
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(2);
int thisPitch = map(sensorReading, 0, 1023, 120, 1500);
// play the pitch:
tone(speaker, thisPitch, 10);
delay(1); // delay in between reads for stability
val = map(val, 0, 1023, 0, 29);
if (val <= 9) {
digitalWrite(bluepin, HIGH);
digitalWrite(greenpin, LOW);
digitalWrite(redpin, LOW);
}
else if (val > 9 && val <= 19) {
digitalWrite(bluepin, LOW);
digitalWrite(greenpin, HIGH);
digitalWrite(redpin, LOW);
}
else if (val > 19) {
digitalWrite(bluepin, LOW);
digitalWrite(greenpin, LOW);
digitalWrite(redpin, HIGH);
}
}
Video Link
http://myhub.pixorial.com/watch/f6a291957a7e9da6de9a83934c71435d
Images
- Login to post comments