Finally, it was time to get my Arduino to talk to my p5 sketch. The last time I tried this I made a big mistake with my setup so the Arduino was constantly sending serial messages and overloading the serial port buffer. This created a huge lag on the p5 end. I’ve learned from my mistakes and now am checking for state change, so the only time a message will be sent is when the user is pressing a button. When a button is pressed, the Arduino will print out a string with the corresponding flower’s color.
In order to receive messages, I’m using Shawn Van Every’s p5.serialport library. In the serialEvent() function I’m using the serial.readLine() method. I then loop through my flower objects to check for the matching color, so I can draw a path to the correct flower.
As you can see in the video below, everything seems to be working! Now I need to make it work with seven giant arcade buttons, instead of three tiny push buttons.