Serial P5 Lab

Introduction to Physical Computing

10 Oct 2018

Background: This week’s lab was to communicate to p5.js and arduino with a serial connection. Easy. 👍. :smile: :confused::worried::grimacing:

I thought I would have an easy time with this lab since I was familiar with serial connections. In earlier labs I used serial communication through processing to control my board. I’ve used processing for a few years and have incorporated many different protocols in my projects such as midi, serial, osc. I’ve used different programming environments such as OpenFrameworks, and interfaced with TCPSpout. Out of all of these I found getting serial to work with p5 was the biggest challenge as I was hitting one problem after another. :perservere:

Process: Since I’ve been using VSCode as my main editor I opted to try it out for Arduino. After some tedious set up I got the arduino extension installed and connected a simple potentiometer circuit.

FYI for getting the arduino configured in vscode you have to press F1 and bring up the board manager. Make sure to include the Path to your arduino program and select the right configurations.

With this work done, I am getting my expected output to my serial monitor. :100: The next step is to see if I can send it p5. And this is where my problems started.

I’m not a huge fan of using GUIs when they’re not needed so I installed the p5.serialserver via npm. sudo npm install -g p5.serialserver I got a funky error, some blahblah dependencies not there. Hmmmm. I figure its because I haven’t used node in a while, and I’m in version 6.xx. I update my node to the latest version. I follow some help on stack over flow to clean my cache, install a helper, and then install the latest stable version. sudo npm cache clean -f sudo npm install -g n sudo n stable

Check my vesion.. node -v and I’m now on v8.2.1.

Might as well update my npm. npm update. Now I am able to successfully install p5.serialserver via npm. I run it using p5serial :warning: I get an error Error: Could not locate the bindings file. ... At this point i’m over using npm so I head over to the git repo https://github.com/vanevery/p5.serialport.git and clone it in to my project folder. I run it locally using node startserver.js and get the beautiful message p5.serialserver is running. Yay.

Next I write some html and make a p5 sketch to write my sensor values in. Everything is looking good.. server is running, port is opened, blalbla, but my sensor value is staying at: -1. Odd.

I head over to the serial monitor is vscode and I’m seeing that my sensor is reading the correct value, so it must be somewhere in my serial connection.

💀

Lets back up. Am I doing the right steps? I’ll go back one lab. I’ll first make sure I am sending serial at all.

Yadidadi still working on it :sweat: