I am starting to use asynchronous serial communication to connect what we are doing with the Arduino in P Comp with what we are doing with p5 in ICM. It’s pretty exciting with all the new possibilities, but first I wanted to see if I could use two sensors to make changes in a pre-existing p5 sketch I had.
First I set up my breadboard and Arduino. As I’ve done many times before, I have a simple set up with my potentiometer and photoresistor connected to the analog inputs.
I wanted to use my potentiometer and my photoresistor to make changes to my sketch. To keep it simple and so I could see the direct change, I decided to play with the size of the creatures and bubbles in my underwater sketch. First, I wanted to get the sensor values from my Arduino. Here is my code I loaded up to the Arduino.
Now, I had a “factor1” controlled by the potentiometer and a “factor2” controlled by the photoresistor. I used these variables as size factors in the functions for the jellyfish, fish, and bubbles. A small gif of the sketch in action is below. You can see when I turn the potentiometer the fish change size, and then when I cover and uncover the photoresistor the bubbles change size.
Now I am thinking of new ways to combine different interactions on the screen with physical interactions that can be detected by sensors. Reworking this early p5 sketch has been a good exercise, and I am planning on making something where the actions caused by the physical interactions make more sense.