Processing Code:
import processing.serial.*; Serial myPort; int valueFromArduino; import processing.video.*; Capture cam; void setup() { size(640, 480); cam = new Capture(this, 640, 480); cam.start(); printArray(Serial.list()); myPort = new Serial(this, Serial.list()[2], 9600); } void draw() { // to read the value from the Arduino while ( myPort.available() > 0) { valueFromArduino = myPort.read(); } if (cam.available()) { cam.read(); } image(cam, 0, 0); if (valueFromArduino > 200) { filter(INVERT); println(valueFromArduino); } }
Arduino Code (Input)
const int ledPin = 3; const int sensorPin = A0; int value; void setup(){ pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop(){ value = analogRead(sensorPin); value = map(value, 0, 1023, 0, 255); Serial.println(value); analogWrite(ledPin,255-value); delay(100); }
Arduino Code (Communication)
void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(A0) / 4; Serial.write(sensorValue); delay(10); }
Arduino Circuit:
Result:
Upon activating the force sensor, the colors of the video input invert.
In Computer Vision for Artists and Designers, the author discusses the application of technology in various fields not traditionally related to technology. Softwares like Processing allow a new focus on the potential visual applications of technology, specifically in the field of visual arts. My code used the computer camera in order to collect visual input, and used Processing’s language to invert the colors from this input. This inversion was activated by a force sensor that the user interacts with.