So I've always had an interest in computer hardware. In fact my degree is technically in Computer Engineering, which is almost more of a "specialization" of Electrical Engineering (all this as opposed to say, Computer Science). Anyways, I've enjoyed the limitations involved with hardware. It is not what I really do on a day to day basis; my career has been more software centered, but I've never really lost that desire to make LEDs blink or drive servos over a UART πŸ˜†.

All that to say, I got it into may head to start tinkering with Arduino. I had a couple Atmel/Pic32 projects but writing in C fet a bit more laborious to get setup and I just wanted to get moving. Specifically, I wanted to play with Neopixels.

I figured to start out, I could just talk over a USB/Serial port to the microcontroller and control the LEDs that are connected over the I2C (say "I Squared C" interface). Arduino has their own software IDE and language called Processing that is kind of a cross between C and C++ with some really nifty built-in functions for getting IO setup quickly. I'm also the kind of person who asks for "circuit stuff" for Christmas, so I had a protoboard to setup connections.

Arduino protoboard with ring LED
Arduino protoboard with ring LED

So this was the initial setup. I had a ring of 12 LEDs that I could control over the I2C interface. The Arduino IDE has a built-in serial monitor that you can use to send commands to the microcontroller and get responses back. I wrote a simple sketch that would take in a command and then set the color of the LEDs based on the command.

I wrote a bunch of simple little animations to play with and a big serial command parser loop to just switch via the terminal.

Processing
1void loop() { 2 // Clear the ring 3 clearRing(); 4 5 // Main loop when we're not taking serial commands 6 while(Serial.available() == 0) { 7 if(command == "arc") { 8 arcReactor(ring); 9 } else if(command == "spin") { 10 rainbowSpin(ring); 11 } else if(command == "rainbow") { 12 rainbow(ring); 13 } else if(command == "pulse") { 14 pulseColor(ring, pulse); 15 } else if(command == "fire") { 16 fire(ring); 17 } else if(command == "pixels") { 18 int pixelPulse = pulse.run(); 19 int color = ring.Color(0, 0, pixelPulse); 20 pulsePixel(ring, color, 8); 21 pulsePixel(ring, color, 9); 22 pulsePixel(ring, color, 10); 23 } else if(command == "") { 24 // Idle states 25 } else { 26 // Reset the arc variables if we stop using it 27 arcReset(); 28 29 // Clear the ring 30 clearRing(); 31 32 command = ""; 33 } 34 } 35 36 // Get a command (we'll parse it in the loop above) 37 command = Serial.readString(); 38 command.trim(); 39 Serial.println(command); 40}

This link is really to a commit that should represent roughly where I was when I had something up and running for serial processing and controlling the Neopixels. The big thing is that the good folks at Adafruit have a great library for controlling Neopixels, so I was able to just use that and not worry about the low-level details of the protocol.

This is really the basics of what I wanted. And my favorite is the little animated "fire" mode that looks like a small campfire. I like to put my Funko Gimli next to it like he's in the forests of Fangorn πŸͺΎπŸͺ“. This really just got the ideas generating for what I could do with this kind of setup.