I decided to use one of my previous processing sketches and incorporate serial communication into it. The processing sketch I used was my self-portrait. I decided that I wanted to create something that could be used in a party. When the light dims down, the kaleidoscopic-like portrait would fade onto the wall. The project is hyperlinked here. The code I used is incorporated below, I used the handshake technique between processing and Arduino:
Self-portrait:
void setup(){ size(480,640); //w,h frameRate(5); //fill(255,192,203); //ellipse(240,400,100,100); } float radius; void draw(){ background(0, 0, 0); fill(0); stroke(255); ellipse(240,325,730,800); stroke(255); ellipse(240,325,630,700); stroke(255); ellipse(240,325,530,600); stroke(255); ellipse(240,325,430,500); stroke(255); ellipse(240,325,330,400); stroke(255); ellipse(240,325,230,300); fill(255); stroke(0); ellipse(240,200, 150, 190); fill(255); ellipse(115,350, 50, 80); fill(255); ellipse(365,350, 50, 80); fill(0); ellipse(100,370,5,5); fill(0); ellipse(100,370,5,5); fill(0); ellipse(379,370,5,5); fill(random(0, 204), random(0, 255), random(0, 255)); ellipse(240,330,275,350); //x,y,w,h fill(255); ellipse(240,360,275,350); //x,y,w,h fill(random(0, 255), random(0, 255), random(0, 255)); ellipse(300,340,75,75); //glasses 1 fill(random(0, 255), random(0, 255), random(0, 255)); ellipse(180,340,75,75); //glasses 2 line(216, 340, 264, 340); //middle portion of glasses line(104, 340, 141, 340); //side portion of glasses line(336, 340, 375, 340); //side portion of glasses fill(255); stroke(0); arc(240, 410, 50, 35, PI, PI+QUARTER_PI); arc(225, 410, 20, 20, HALF_PI, PI); arc(270, 450, 170, 50, HALF_PI, PI); arc(170, 440, 50, 35, PI, PI+QUARTER_PI); arc(260, 485, 100, 10, HALF_PI, PI); arc(260, 470, 50, 30, PI+QUARTER_PI, TWO_PI); arc(210, 460, 60, 30, PI+QUARTER_PI, TWO_PI); fill(0); ellipse(225, 410, 3, 3); //fill(0); //stroke(255); //ellipse(240,150,115,130); stroke(0); line(257, 410, 255, 380); }
Arduino:
bool ledState=LOW; int knobpin = A1; int led=3; void setup() { Serial.begin(9600); pinMode(led, OUTPUT); Serial.write(0); // put your setup code here, to run once: } void loop() { if(Serial.available()>0){ //if arduino receving something int inByte=Serial.read();//when you read something off buffer, it goes off the buffer int readvalue=analogRead(knobpin); //knob int writevalue = map(readvalue,0,1024,0,255); Serial.write(writevalue); analogWrite(led,writevalue); delay(1); }
I wanted to add more elements to this project such as adding music using an mp3 shield once the processing sketch is revealed. I also wanted to add a flex sensor that would simulate a wristband on people. Every time it moved, making the assumption that it moved because they people were dancing, my glasses would start changing color (as it does already). I have had tremendous difficulty coding this, and because I got slightly injured I didn’t have the time to go back and work on this aspect. If I am able to complete my weekly project for this week on time, I really want to spend some time enhancing this project.