Screen capture of p5js communicating with arduino

Week 6: Serial Communciation between p5.js and Arduino

Demo video

p5.js sketch source code

This week we explored serial input and output and using serial communication between p5.js and arduino. Using what I learned, I made a small prototype controlling a p5.js sketch with a potentiometer and ultrasonic sensor.

How it works

Experimenting with different representations of serial communication values: ascii, binary, octal, hexadecimal
Arduino uno connected with an ultrasonic sensor and potentiometer
A snapshot of the p5.js and arduino code

I reused a p5.js particle sketch I made before to put in my blog's main header.

The arduino code reads and smooths values from the potentiometer, and sends to the p5 sketch using the p5.serialcontrol app and p5.serial library.

The potentiometer's value controls the spinning circles' radius, while the ultrasonic sensor's proximity controls the spinning circles' distance and color hue.