Screen Shot 2018-01-27 at 11.00.17 PM.png

Hi.

Welcome to my blog. Here, I document my daily blogs, learning experiences, and some fun projects.

Serial output from p5.js

Serial output from p5.js

For this week’s lab, I controlled the ‘HIGH’ and ‘LOW’ state of an LED by using the ‘H’ and ‘K’ keys on my keyboard respectively. The LED is connected to the circuit board using a 220 Ohm resistor. As for the p5 sketch, I need only two functions, function serialEvent() and function serialError() in order to read the incoming data and report an error if there is any. For the Arduino IDE, I let the incomingByte be the variable to read the incoming serial data into. In my voidLoop() function I then state that if there is an incoming serial data, first read it, and if it is uppercase ‘H’, then change the state of the LED pin to HIGH. Similarly, if the incoming data is an uppercase ‘L’, then change the state of the LED pin to LOW. The reason that the letter has to be ‘H’ and ‘L’ and not ‘h’ and ‘l’ is that the upper and lower case characters have different ASCII values. 

Candy Dispenser: PComp Midterm

Candy Dispenser: PComp Midterm

Pcomp Lab: p5js sketch using potentiometer

Pcomp Lab: p5js sketch using potentiometer