CMS3 Final Project - Swallow the Universe
2014年5月12日 星期一
Arduino codes of the work
int potPin = 2;//connect one leg of the potentiometer to analog pin2
int val = 0;// to store values in the variable "val"
void setup(){
Serial.begin(9600);
}
void loop(){
val = analogRead(potPin);// to read the analog value from the potentiometer
Serial.write(val); // to write the value to the processing
delay(100);
}
Processing codes of the work
//To Connect the Arduino with the Processing
import processing.serial.*;
int val= 0;
Serial myPort;
int N=400;
int fatness=20;
int step=10;
int bg =0;
int bg2 =0;
int bg3 =0;
float[]r= new float[N];
float[]as= new float[N];
float[]ca= new float[N];
void setup() {
myPort = new Serial(this,"/dev/tty.usbmodemfd1411",9600);//To connect the Serial port
frameRate(60);
size(1280, 920);
smooth();
for (int i = 0; i< N; i++) {
r[i] = 50+ i;
as[i] = random(-PI/90, PI/90);
ca[i] = random(-PI, PI);//Pi = half circle, two pi = whole circle)
}
}
void draw() {
background(0);
frameRate(60);
star(70, 20, 2);
//when the value of the potentiometer is larger than 100, more planets(ellipses) will appear
if (val >100) {
rotate(radians(22));
star(70, 20, 2);
}
//when the value of the potentiometer is larger than 150, a black hole is called
if (val>150 ) {//call the black hole (nearest)
frameRate(60);
float c=400;
float b=1;
fatness = fatness + step;
fill(0);
ellipse(0, 0, fatness+c, fatness+c);
star(20, 20, 2);
fill(0, 0, 0, 90);
ellipse(30, 1, fatness+b, fatness+b);
fill(0, 0, 0, 95);
ellipse(34, 2, fatness+b, fatness+b);
fill(0, 0, 0, 99);
ellipse(38,3, fatness+b, fatness+b);
fill(0, 0, 0);
ellipse(42,4, fatness+b, fatness+b); }
if (bg>=0&&bg2>=0&&bg3>=0) {
bg+=2;
bg2+=2;
bg3+=2;
}
}
void star(int o, int n, int scalingFactor ) {
for (int i = 0; i< N; i++) {
ca[i]+=as[i];
int p= 1;
//translate the angle X and Y
float x = sin(ca[i]) * r[i];
float y = cos(ca[i]) *r[i];
float k = sin(ca[0]) * r[55];
float m = cos(ca[0]) *r[0];
float g = cos(ca[p]) *r[p];
//draw the ellipse
fill(255, 246, 209, y);
triangle(val+523, 529+y, 527+x, 525+y, 531+x, 529+y);//level 1
noStroke();
rotate(radians(44));
fill(20, 15, k, y);
ellipse(val+500, m+500, 25, 25);//when the value of the potentiometer is changed, the x-coordinates of the ellipses are being changed
fill(20, m, 250, y);
ellipse(val+500, k+500, 25, 25);//when the value of the potentiometer is changed, the x-coordinates of the ellipses are being changed
ellipse(m+500, k+500, 25, 25);
fill(255, 224, 121, x);
ellipse(m+400, k+420, 10, 10);
ellipse(m+280, k+280, 2, 2);
ellipse(m+280, k+280, 2, 2);
ellipse(m+380, k+380, 2, 2);
fill(255, 226, 209, x);
ellipse(m+320, k+320, 6, 6);//level2
fill(255, 246, 209, y);
triangle(m+483, 499+k, 487+m, 495+k, 521+m, 499+k);
fill(255, 102, 0, y);
ellipse(k+450, m+450, 32, 32);
fill(255, 157, 157, x);
ellipse(m+250, k+250, 23, 23);//level3
fill(209, 165, 80, x);
ellipse(m+350, k+350, 15, 15);
fill(99, 252, 243, x);
ellipse(m+380, k+380, 30, 30);//level4
fill(255, 102, 0, y);
triangle(m+300, 305+k, 300+m, 295+k, 305+m, 299+k);
triangle(m+310, 305+k, 310+m, 295+k, 315+m, 299+k);
triangle(m+295, 295+k, 295+m, 285+k, 300+m, 289+k);
// draw the sun
fill(235, 255, 170, y);
ellipse(50, 50, 150, 150);//level6
}
}
void serialEvent(Serial myPort){
if (myPort.available()> 0){
val = myPort.read();
}
println(val);
}
System diagram
Images from Arduino.cc
The sensor we used is called "Potentiometer", an adjustable voltage divider.
The systematic diagram of the hardwares,
The sensor we used is called "Potentiometer", an adjustable voltage divider.
The systematic diagram of the hardwares,
One of the legs of the two sides of the potentiometer is connected to a 5V pin of Arduino, one of the legs is connected to a GND pin of Arduino. The middle leg of the potentiometer is connected to the analog pin 2 of the Arduino.
[Swallow the Universe] - Project description
[Swallow the Universe]
- Project description
The Universe seems far away from we the human and the Earth.
When we look at the sky, we can see sun, moon and stars.
Many of us will be curious what is happening outside the Earth.
There are many imagination about the Universe.
Our project aims at visualizing the Universe with graphic, such as circle and triangle.
We use those shapes to represent different planets.
It tries to encourage people to have the passion to imagine the Universe with funny images.
Also, it is an interactive installation.
In our idea, this installation will display on a wall though a projector and set a button for
people to control the potentiometer.
People can use the potentiometer to add the numbers of the planets
and initiate the appearance of the black hole. When the value of the potentiometer is larger than 100,
more planets appear and the graphic looks more fruitful.
Then, a black hole appears when you keeping turning the potentiometer up to value of 150 above.
It will start to swallow the whole universe .
Planets are expanding outwards , they look like to escape but they can't.
Through this function, it hopes to make people feel closer to the Universe.
訂閱:
意見 (Atom)






