In this video, I’m controlling the pixelization of an image with a potentiometer that’s connected to an Arduino. Here’s a brief overview of how it’s done:
• The Arduino is sending the value of the potentiometer to my laptop via USB with Serial.println();
• Node.js is reading the incoming data on the serial port with the SerialPort library.
• Node.js passes the serial value to the browser through Socket.io.
• The browser redraws the image in canvas when it gets new serial data. I got the pixelization code from html5canvastutorials.com.
The webapp source is available to download and modify. The Arduino source is very simple:
void setup(){
Serial.begin(9600);
}
void loop(){
int analogIn = analogRead(A0) / 4;
Serial.println(analogIn);
}
© William Lindmeier | wdl225@nyu.edu | @wdlindmeier | Theme by Eleven Themes
Leave a Comment