The Mood Machine is a VJ like instrument where Gemini acts as a light show conductor. Through preset modes that I designed with the help of Gemini, there's a "perceived musicality" to the behavior of the lights without having to go through any FFTs or wave spectrum analysis. I wanted to see how much tempo, color, and pattern could carry the feeling of a genre without any audio input at all.
I started the process with a simple potentiometer and LED. At this stage I just needed to understand Gemini's API, the connection between Python and Arduino, and how to connect Gemini to the hardware. It was during this phase that I hit my first challenge:
Initially I kept getting 429 errors, which are rate limit errors. I'd never used the Gemini API before, so I thought I was doing something wrong. I was using the serial port to communicate between Python and Arduino. This is how I always communicate between Python and Arduino, so I didn't see anything wrong with it, but the more that I thought about it the more I realized that I was sending a ton of data through the serial monitor. Arduino's Serial Monitor is relatively slow but at a baudrate of 9600 it can send 960 characters a second and the serial monitor is streaming data every 10-50 milliseconds. That hundreds of thousands of requests per second! Definitely over the free tier's limit 😅.
To get around that I added a button to my circuit and a timer in my code so that data only gets sent when I press the button. If I continue holding down the button another request won't be sent until 3 seconds have passed. With that, my problem was completely solved!
Once I had communication with all parties established, I replaced the LED with a strip of Neopixels.