P Comp Week 6 Labs

Intro to Asynchronous Serial Communications

A Serial Output Sketch

A had a bit of an issue starting this lab where my Arduino would not power on. It wasn’t the USB cable, and it would power on if I unplugged the Arduino from my breadboard, so it had to be something connected on the board. I unplugged everything trying to find the problem, turns out it was a bad pot. So I swapped it out for another and the Arduino turned on and I was able to move on with the labs.

Sending the Data in Many Formats

Formatting Multiple Serial Date: Punctuation

With two potentiometers.

With two potentiometers and a pushbutton.

Flow Control: Call and Response (Handshaking)

Serial Input to P5.js

Program P5 to List the Available Serial Ports

Reading a Sensor and Displaying the Results in P5

I had one small hiccup here where the port kept reading ‘undefined’. I was reading through my code to see if I had missed or misspelled anything when I noticed my port name was “/dev/cu.usbmodem143201” which is what it is in Arduino IDE, however in the p5.serialcontrol software it reads “/dev/tty.usbmodem143201”, so once I fixed the name it worked.

Adding A Serial Port Select Menu

Draw a Graph With the Sensor Values

Serial Output from P5.js

Controlling the Brightness of an LED with P5

Sending ASCII-Encoded Serial Data

Program P5.js to Control the LED

Adjusted the keyPressed function to turn the LED on or off when ‘H’ or ‘L’ is pressed on the keyboard.

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: