For this lab, I’ll be using the circuit from Intro to Async lab since I have my potentiometer set up.
Potentiometer Pin: A5
Adding the webserial library to p5js
Sketch for Serial communication
void potentioReading(){
int analogValue = analogRead(pPin);
int mappedValue = map(analogValue, 0, 1023, 0, 255);
Serial.write(mappedValue);
delay(10);
}
Output on p5js
Sketch for drawing a graph
p5js output
function serialEvent() {
inData = Number(serial.read());
console.log(inData);
print(inData);
}
function serialEvent() {
// inData = Number(serial.read());
inData = serial.readLine();
console.log(inData);
print(inData);
}