Difference between revisions of "Msc2G5:Final"
Line 59: | Line 59: | ||
[[File:02.jpg|800px]] | [[File:02.jpg|800px]] | ||
<youtube width="800">fwf9ajSNb2g</youtube> | <youtube width="800">fwf9ajSNb2g</youtube> | ||
+ | |||
+ | <pre> | ||
+ | //======================================== | ||
+ | //INITIALIZATION | ||
+ | //======================================== | ||
+ | |||
+ | #include <Adafruit_NeoPixel.h> | ||
+ | #include <VarSpeedServo.h> | ||
+ | #ifdef __AVR__ | ||
+ | #include <avr/power.h> | ||
+ | #endif | ||
+ | |||
+ | #define PIN 2 | ||
+ | #define LED_COUNT 50 | ||
+ | |||
+ | Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ400); | ||
+ | |||
+ | //******************************** | ||
+ | //Servo motors | ||
+ | //******************************** | ||
+ | |||
+ | //small spheres: the MG960R's | ||
+ | VarSpeedServo servo180_1; | ||
+ | VarSpeedServo servo180_2; | ||
+ | VarSpeedServo servo180_3; | ||
+ | VarSpeedServo servo180_4; | ||
+ | |||
+ | //big ball: the FS511R | ||
+ | VarSpeedServo servoTwister; | ||
+ | int servospeed = 20; int notify = 0; int stepcount = 0; | ||
+ | |||
+ | //******************************** | ||
+ | //Loudness sensor and strips | ||
+ | //******************************** | ||
+ | |||
+ | //loudness parameters | ||
+ | int loudnesssignal = 0; | ||
+ | float acceptable = 90; | ||
+ | float unacceptable = 275; | ||
+ | float dangerpivot = (unacceptable + acceptable)/2; | ||
+ | |||
+ | //light | ||
+ | float intensity = 255; | ||
+ | float rr = 0; | ||
+ | float bb = 0; | ||
+ | float gg = intensity; | ||
+ | float inc = 1; | ||
+ | |||
+ | //counter | ||
+ | float count = 0; | ||
+ | float countlimit = 500; | ||
+ | float totalsignal = 0; | ||
+ | float refsignal = 0; | ||
+ | |||
+ | //======================================== | ||
+ | //PROGRAM | ||
+ | //======================================== | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | //******************************** | ||
+ | //Setup | ||
+ | //******************************** | ||
+ | Serial.begin(9600); | ||
+ | strip.begin(); | ||
+ | strip.show(); // Initialize all pixels to 'off' | ||
+ | |||
+ | servo180_1.attach(5); | ||
+ | servo180_1.attach(6); | ||
+ | servo180_2.attach(9); | ||
+ | servo180_4.attach(10); | ||
+ | |||
+ | servoTwister.attach(3); | ||
+ | servoTwister.write(93); //keep the continuous servo still while starting up | ||
+ | } | ||
+ | |||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | //******************************** | ||
+ | //Loudness sensor and strips | ||
+ | //******************************** | ||
+ | |||
+ | //read the loudness sensor | ||
+ | analogRead(0); | ||
+ | loudnesssignal = analogRead(0); | ||
+ | |||
+ | //counting loop (for averaging signal values) | ||
+ | if (count < countlimit) {totalsignal += loudnesssignal; count+=1; } else { refsignal = totalsignal/countlimit; totalsignal = 0; count=0; } | ||
+ | |||
+ | //regulate gradual transition between lightstrip states | ||
+ | if (refsignal < acceptable) {if (gg > intensity) gg-=inc; if (gg < intensity) gg+=inc; if (rr > 0) rr-=inc; if (rr < 0) rr=0; } else //to green | ||
+ | if (refsignal > acceptable && refsignal < dangerpivot) {if (gg > intensity) gg-=inc; if (gg < intensity) gg+=inc; if (rr > intensity) rr-=inc; if (rr < intensity) rr+=inc; } else //to yellow | ||
+ | if (refsignal > acceptable && refsignal > dangerpivot) {if (gg > 0) gg-=inc; if (gg < 0) gg=0; rr=intensity; if (rr > intensity) rr-=inc; if (rr < intensity) rr+=inc; } //to red | ||
+ | |||
+ | //update the lightstrip | ||
+ | for(uint16_t i=0; i<strip.numPixels(); i++) | ||
+ | { strip.setPixelColor(i,strip.Color(gg,rr,bb)); } | ||
+ | strip.show(); | ||
+ | |||
+ | //******************************** | ||
+ | //Servo motors | ||
+ | //******************************** | ||
+ | |||
+ | //manual control over movement | ||
+ | if (Serial.available()) | ||
+ | { | ||
+ | notify = Serial.parseInt(); | ||
+ | if (notify == 1) servoTwister.write(180); | ||
+ | if (notify == 0) servoTwister.write(93); | ||
+ | servo180_1.slowmove(toAngle(150,20,0), servospeed ); | ||
+ | servo180_2.slowmove(toAngle(180,20,0), servospeed ); | ||
+ | servo180_3.slowmove(toAngle(180,20,0), servospeed ); | ||
+ | servo180_4.slowmove(toAngle(150,20,0), servospeed ); | ||
+ | delay(4000); | ||
+ | servo180_1.slowmove(toAngle(0,20,0), servospeed ); | ||
+ | servo180_2.slowmove(toAngle(0,20,0), servospeed ); | ||
+ | servo180_3.slowmove(toAngle(0,20,0), servospeed ); | ||
+ | servo180_4.slowmove(toAngle(0,20,0), servospeed ); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | //function toAngle deals with inaccuracies of the 180-degree turning motor | ||
+ | int toAngle(int inp, int overreach, int tweak) | ||
+ | { | ||
+ | int tweak = 0; int overreach = -20; | ||
+ | return tweak + overreach + map( inp,0,180,0,180 - overreach); | ||
+ | } | ||
+ | </pre> |
Revision as of 12:47, 9 July 2017
The concept is composed of the following aspects:
Acoustic properties
- Sound ceiling with acoustic properties, passes down data to the LED painting
Time layers
- Short term layer (mostly interesting for children)
- Long term layer (mostly interesting for adults)
Reflection
- Paint a picture of the sound over the long-term
Experiment #1
Single hoberman sphere, plastic surface with cotton/viscose finishing
Experiment #2
Mechanical arms for expanding and compressing the spheres without strings
Prototype 1
Prototype 2
Experiment #3
More mechanical arms and materialsamples
Materialsamples: Sheep wool on top of a polyester acoustic surface. The sheep wool is fireproofed:
it does not catch fire but turns into coal instead. The polyester surface is fire retardant.
//======================================== //INITIALIZATION //======================================== #include <Adafruit_NeoPixel.h> #include <VarSpeedServo.h> #ifdef __AVR__ #include <avr/power.h> #endif #define PIN 2 #define LED_COUNT 50 Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ400); //******************************** //Servo motors //******************************** //small spheres: the MG960R's VarSpeedServo servo180_1; VarSpeedServo servo180_2; VarSpeedServo servo180_3; VarSpeedServo servo180_4; //big ball: the FS511R VarSpeedServo servoTwister; int servospeed = 20; int notify = 0; int stepcount = 0; //******************************** //Loudness sensor and strips //******************************** //loudness parameters int loudnesssignal = 0; float acceptable = 90; float unacceptable = 275; float dangerpivot = (unacceptable + acceptable)/2; //light float intensity = 255; float rr = 0; float bb = 0; float gg = intensity; float inc = 1; //counter float count = 0; float countlimit = 500; float totalsignal = 0; float refsignal = 0; //======================================== //PROGRAM //======================================== void setup() { //******************************** //Setup //******************************** Serial.begin(9600); strip.begin(); strip.show(); // Initialize all pixels to 'off' servo180_1.attach(5); servo180_1.attach(6); servo180_2.attach(9); servo180_4.attach(10); servoTwister.attach(3); servoTwister.write(93); //keep the continuous servo still while starting up } void loop() { //******************************** //Loudness sensor and strips //******************************** //read the loudness sensor analogRead(0); loudnesssignal = analogRead(0); //counting loop (for averaging signal values) if (count < countlimit) {totalsignal += loudnesssignal; count+=1; } else { refsignal = totalsignal/countlimit; totalsignal = 0; count=0; } //regulate gradual transition between lightstrip states if (refsignal < acceptable) {if (gg > intensity) gg-=inc; if (gg < intensity) gg+=inc; if (rr > 0) rr-=inc; if (rr < 0) rr=0; } else //to green if (refsignal > acceptable && refsignal < dangerpivot) {if (gg > intensity) gg-=inc; if (gg < intensity) gg+=inc; if (rr > intensity) rr-=inc; if (rr < intensity) rr+=inc; } else //to yellow if (refsignal > acceptable && refsignal > dangerpivot) {if (gg > 0) gg-=inc; if (gg < 0) gg=0; rr=intensity; if (rr > intensity) rr-=inc; if (rr < intensity) rr+=inc; } //to red //update the lightstrip for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i,strip.Color(gg,rr,bb)); } strip.show(); //******************************** //Servo motors //******************************** //manual control over movement if (Serial.available()) { notify = Serial.parseInt(); if (notify == 1) servoTwister.write(180); if (notify == 0) servoTwister.write(93); servo180_1.slowmove(toAngle(150,20,0), servospeed ); servo180_2.slowmove(toAngle(180,20,0), servospeed ); servo180_3.slowmove(toAngle(180,20,0), servospeed ); servo180_4.slowmove(toAngle(150,20,0), servospeed ); delay(4000); servo180_1.slowmove(toAngle(0,20,0), servospeed ); servo180_2.slowmove(toAngle(0,20,0), servospeed ); servo180_3.slowmove(toAngle(0,20,0), servospeed ); servo180_4.slowmove(toAngle(0,20,0), servospeed ); } } //function toAngle deals with inaccuracies of the 180-degree turning motor int toAngle(int inp, int overreach, int tweak) { int tweak = 0; int overreach = -20; return tweak + overreach + map( inp,0,180,0,180 - overreach); }