Recitation 10: Image & Video
Freddie
For Arduino, I made a three-potentiometers circuits that controls three values respectively. The code for Arduino is quite simple. It is based on the serial example SendMultipleValues. So the only thing I do is to add one more values and change all the input into A0, A1 and A2. The circuit was also not difficult to make. It looks like this:
For Processing I planned to change the color background of an image which was taken on the day before the recitation when I used the mirror and create a weird figure of myself. The three values control three basic color red, green and blue respectively.Since the value of each potentiometer is 0 to 1023, so if I divide each original value by 4, I get new values from 0-256 which is almost the same range as the RGB range 0-255. There is a function in the image effect called “tint();”, which can change the color of the whole image. I replace certain numbers with three values and tried and saw the effect like this:
And I created some Stranger Things effect like this:
Here is the Arduino code:
Here is the Processing code:
PImage photo; import processing.serial.*; import osteele.processing.SerialRecord.*; Serial serialPort; SerialRecord serialRecord; void setup() { size(1024, 512); photo = loadImage("one eye.png"); String serialPortName = SerialUtils.findArduinoPort(); serialPort = new Serial(this, serialPortName, 9600); serialRecord = new SerialRecord(this, serialPort, 3); } void draw() { serialRecord.read(); int value1 = serialRecord.values[0]/4; int value2 = serialRecord.values[1]/4; int value3 = serialRecord.values[2]/4; image(photo, 0, 0,width, height); tint(value1, value2, value3); }