Followed along with the lab:
a.) Set up breadboard
b.) Program p5.js for serial communication
See video below for example of the keyPressed() function and mouseDragged() function
c.) Mousedragged() function in p5js to change the values displayed on the p5.js canvas and the LED brightness.
d.) keyPressed() function in p5js reading the pressed keys 0-9 and the LED changes depending on the # pressed.
e.) keyPressed function to read H or L in order to effect the LED.
Notes for self:
1.) “println” doesn’t work in p5.js. It has to be “print”.
2.) “serial.read line()” in p5.js works with “println()” in Arduino. p5.js reads ASCII and arduino prints ASCII.
3.) “parseInt()” in Arduino: converts p5.js string into an Arduino integer. It parses out the ones that are not integers.
1.) For the keyPressed() function, why is the “outByte” defined as a “byte” and not “int”, like the mouseDragged() function? I will try both and update the results.
2.) Tried sending ASCII encoded strings with Arduino and I think I need more clarification with parseInt(). Why and when do we use parseInt()?