"Vibe coding" Spin with Gemini

I've been working with LLMs out there in my regular work, and since the Open House is coming, I thought it might be fun to try working with Spin and seeing what one of them can do. Since Spin has been out a long time and the OBEX is up on GitHub, I figured that everything in it has been absorbed. On the other hand, I've also found that projects not using common web languages run into all kinds of problems pretty quickly.
My demo idea was to use an ultrasonic distance sensor, and a strip of Neopixels. The Neopixels start out all lit up, and as you move your hand closer to the sensor, they turn off - kind of a manually controlled bar graph.
First I tried Claude. Ugh, it had a hard time getting Spin right. Eventually it got late and I gave up.
A couple of nights later I tried Google's Gemini in Google AI Studio. It also struggled, but was much better about understanding its errors and fixing them. I started with having it read the ultrasonic sensor and display the distance. It had to fix three bugs, like this one:
Error: Expected a constant, unary operator, or "("
On this line: US_PER_TICK = 1_000_000 / clkfreq
It did it pretty fast and then the code worked - the ultrasonic sensor shows the distance on the PST.
So it was onto the Neopixels. It struggled with getting it right - until I gave it the current version of jm_ws2812b.spin from the Obex by pasting it into the chat. Then it analyzed it and did a new version of the Neopixels, and got it right.
Finally I asked to combine the two:
Use the Ultrasonic sensor to read the distance and light up the string of 8 Neopixel LEDs. The ultrasonic sensor should read a hand at 1 meter, and light up the entire string of Neopixels. As you move your hand closer to the ultrasonic sensor, the Neopixels follow it and turn off from the farthest point. So the effect is that the line of lit Neopixels gets shorter as you move your hand closer to the ultrasonic sensor.
And it got that right.
This is currently sitting on my desk and is fun to play with. Anyone want me to bring it to the Open House?
Comments
Yes! I haven't exactly welcomed our AI overlords, but I'd like to see what you've done