pcomp help session: serial communication


  • Serial.write(65): sends one byte (encodes in binary)
    • sends 65
  • Serial.print(65): sends two bytes (sends as a string)
    • sends 54 53
  • serial monitor interprets everything as ASCII


  • callback functions need to be defined in draw()
  • Serial.read() with Serial.write()
  • Println() + readLine()
    • readLine() looks for println() to execute


  1. Serial print values from Arduino
  2. Run p5.serialcontrol app
  3. Include serial.js library in index.html of sketch
  4. create serial object in p5 and define callback functions


Arduino code


p5 code

Leave a Reply

Your email address will not be published. Required fields are marked *