Recitation 10
I wanted to create the animation of light blooming in the dark using the following picture.
And I used a light sensor to apply statistics to control the size of the picture. The process of coding and circuiting is quite well. However, the final animation is not that beautiful, it’s mainly because the background of the picture is not black and I used black as the background of the processing canvas, that brings about problems.
The following are the codes and the video:
Arduino:
#include "SerialRecord.h" SerialRecord writer(1); void setup() { Serial.begin(9600); } void loop() { int value = analogRead(A0); writer[0] = value; writer.send(); delay(20); }
Processing
import processing.serial.*; import osteele.processing.SerialRecord.*; PImage light; Serial serialPort; SerialRecord serialRecord; void setup() { size(432, 768); String serialPortName = SerialUtils.findArduinoPort(); serialPort = new Serial(this, serialPortName, 9600); serialRecord = new SerialRecord(this, serialPort, 1); light = loadImage("1.jpeg"); } void draw() { background(0); serialRecord.read(); int value = serialRecord.get(); imageMode(CENTER); image(light,216,384,value*432/1000*2,value*768/1000*2); }
Video and Circuit:
Leave a Reply