Going Serial

Serial communication between arduino and p5.js is every exciting and opens up a lot of opportunities. For this week’s lab, I connected a light puzzle game I made with arduino to p5. The goal of the game is to have all lights lit up by pressing a combo of buttons.

Here is the result:

LED Puzzle Game from Carrie Sijia Wang on Vimeo.

 

I have 4 digital reads from the 4 LED lights. Originally I wanted to separate the string coming in and use each of the readings separately. For example, if the first light is on, draw a circle at (10,10), if the second light is on, draw a circle at (50,10), etc..

I used the split() function in p5, somehow it did not work out, and only the first number in the string got caught.

Eventually I decided to just print out the values of the string for now and resolve the split string problem in the coming week.

Here is my arduino code:

https://github.com/re7l/Arduino-Projects/tree/master/oct15_2017_lighting_game

And here is my p5 sketch:

http://alpha.editor.p5js.org/re7l/sketches/HkjM30sn-

1Comment

Post A Comment