Going back to my sketches to find one that would work well with a controller, I instantly thought of my shy ellipse. I hadn’t played around with the photocell sensor yet, so it also came to mind very quickly — initially I thought it’d be cute to make the ellipse become shy once I covered the sensor, as if I’m touching or tickling it and that’s why it’s blushing.
Once again, I had a bunch of technical issues. At first, I was just trying to test the photocell and LED on the breadboard (using Scott’s code), but all of a sudden my Arduino just would not connect. The USB port didn’t show up at all. I looked it up in forums, tried a different USB cable, installed and updated a bunch of software, even resorting to installing everything anew in a different laptop — nothing worked. I thought I somehow fried the board. I reached out to Scott, who figured out I had to press the reset button twice and suddenly I could see the port again. Yay!
So the code worked in that test run, but when trying to connect it to my p5js code, I had quite a few issues with the serial communication too. Nothing particularly interesting, just sometimes it wouldn’t connect (and sometimes it wouldn’t let me close the port, so I could try again). I had to quit and restart both the Arduino program and the serial control program, and also reset the breadboard, quite a few times before it finally worked. Here’s how the Arduino code looked at that point — extremely similar to Scott’s code linked above, but without the LED output, and printing the value to serial.
In updating my p5js code, I cleaned it up a bit from last time (using classes instead of functions now). Figuring out how to make the “shyness level” relate to the sensor was pretty straightforward — I just had to replace the mouse/center point distance formula in my setAlpha function with the value calculated by the sensor. Like I mentioned, I initially thought of making the ellipse shy as I covered the sensor, but I found that to be harder to control. The effect was really faint, maybe given the light level in my room — but no matter how thoroughly I covered the sensor, the ellipse was never fully gray. I realized while testing it out that my phone flashlight worked really well, so I decided to revert the idea. Here’s how that turned out:
I think this ends up working better — it’s as if the flashlight is “catching” the ellipse or something. In a dark room, getting a bright light shoved in your face might make you a little flustered too.