Shared:Group 4

From ip
Jump to: navigation, search

Flower blooming process in reaction to people interaction , by Danny, Boyuan

  • We are trying to make a living organism which stimulate the flower blooming process. We are inspired by the slow opening process of the flower blooming which can calm people emotion and slow down people movement. By creating a living flower interacts with human movement, it can attract the people to stop and appreciate the flower blooming process.
  • When there is no people around it, the flower will open and close on its own. When someone is there, the flower will start to interact with the human movement so as to create the corresponding response.

Boyuan Danny-01.jpg

Initial Sketch

Boyuan Danny-01-01.jpg Sketch for workshop 2.jpg

Concept and implementation

Boyuan Danny -03.jpg

Boyuan Danny -04.jpg

Boyuan Danny -05.jpg

Boyuan Danny -06.jpg

Boyuan Danny -07.jpg

inspiration -floweing blooming process

Video Sample of Prototype

How it works?

List of things used in the hyperbody Workshop project

  • 1. 6 servo motors
  • 2. 1 ultrasonic sensor
  • 3. 1 loudness senor
  • 4. 1 Arduino/Genuino Uno
  • 5. 1 Arduino Mega
  • 6. 2 external Arduino power supply
  • 7. 1 breadboard
  • 8. 2 3mm wooden board
  • 9. 1 half-translucent plastic sheet
  • 10. 1 ring of 25 Neo pixel LED lights
  • 11. 2 USB line
  • 12. A bunch of wires

Code Sample

The code works by mapping the ultrasonic distance sensor data into the servo motor. So that the shorter the distance the sensor detected, the larger angle the servo motor turns and the flower will open. When the distance recorded is long, the servo motor will turn back to smaller angle and the flower will close.

  • include <Servo.h>
  • Servo myservo1;
  • Servo myservo2;
  • Servo myservo3;
  • Servo myservo4;
  • Servo myservo5;
  • Servo myservo6;
  • Servo myservo7;
  • define trigPin 10
  • define echoPin 11
  • define PREVIOUS_VALS 25
  • int potpin = 0; // analog pin used to connect the potentiometer
  • float val; // variable to read the value from the analog pin


float historyVals[PREVIOUS_VALS];

  • define timeScale 6
  • float averageVals[7 * timeScale];

void setup() {

 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 Serial.begin (9600);
 myservo1.attach(3);
 myservo2.attach(4);
 myservo3.attach(5);
 myservo4.attach(6);
 myservo5.attach(7);
 myservo6.attach(8);
 myservo7.attach(9);
 float initialVal = 90;
 for (int i = 0; i < PREVIOUS_VALS; i++) {
   historyVals[i] = initialVal;
 }

}

void loop() {

 float duration, distance;
 distance = 9999999;
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = (duration / 2) * 0.0344;
 Serial.println(distance);
 delay(30);


 if (distance > 100 || duration > 500000) {
   distance = 50;
 }
 val = mapfloat(distance, 1, 50, 50, 180);   // scale it to use it with the servo (value between 0 and 180)
 //Serial.println(val);
 //Serial.println(val, 10);
 addValToHistory(val);
 float currentAverage = averageVal();
 addAverageToHistory(currentAverage);
 writeServos();


 delay(10);

}


float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {

 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

}


float averageVal() {

 float total = 0;
 for (int i = 0; i < PREVIOUS_VALS; i++) {
   total = total + historyVals[i];
 }
 float average = total / PREVIOUS_VALS;
 return average;

}

void addValToHistory(float v) {

 for (int i = 0; i < PREVIOUS_VALS - 1; i++) {
   historyVals[i] =  historyVals[i + 1];
 }
 historyVals[PREVIOUS_VALS - 1] = v;

}

void addAverageToHistory(float av) {

 for (int i = 0; i < 7 * timeScale - 1; i++) {
   averageVals[i] =  averageVals[i + 1];
 }
 averageVals[7 * timeScale - 1] = av;

}


void writeServos() {

 int i = 7 * timeScale - 1;
 
 myservo1.write(averageVals[i]);
 i = i - timeScale;
 myservo2.write(averageVals[i]);
 i = i - timeScale;
 myservo3.write(averageVals[i]);
 i = i - timeScale;
 myservo4.write(averageVals[i]);
 i = i - timeScale;
 myservo5.write(averageVals[i]);
 i = i - timeScale;
 myservo6.write(averageVals[i]);
 i = i - timeScale;
 myservo7.write(averageVals[i]);

}