Serial + Dom

To try out serial communication and the dom library, I made an etch a sketch application that allowed the user to change the color of the “sketch” and see it in an led.
P5/HTML Code
Arduino Code

After trying out the using node and serialport, I decided to simply use the p5 serial control app. I first started by creating some sliders in P5 that selected a background color of a canvas. Then I sent that color data to arduino to control an rgb led. I chose to only send data when a slider was released; the data output from p5 looked like “RXXX” or “GXXX”. I first tested my protocol in the arduino ide and serial monitor, and it worked. Once having the p5 sketch set up, I told the arduino to send back the end value sent to the led so I could debug (the led was anode so I mapped the values in reverse).

I think I had a problem with overly sending serial data but I didn’t successfully debug it.

This more or less worked, though behaved weird at some values and was slow….. To continue, I decided to make an etch a sketch like application. I’d have to potentiometers choosing where on the screen to draw, and I could change the color with my sliders in p5. The led would indicate what color I was currently drawing with.

I once again defined a protocol for sending data from my arduino; I only sent potentiometer data when a significant change was detected. When that happened, I’d send an X or a Y followed by my pot data.

Here it is all working

Leave a Reply