Old Files & Tiny Controllers

I haven’t done any development on Peregrine Constellation this last week, but while I was cleaning out my Documents folder I saw my old Longboard Lights project that I created back in 2021 so I decided to do a little write up on it. I guess that can count as my blog for this week. Here you go. Enjoy.

Overview

LUX Longboard Automation was my first introduction to C and my first introduction to microcontrollers. Over the summer of 2021, I was working at a summer camp in the mountains of California. There wasn’t any cell service or anything for three months, so I did a lot of reading. One of those books was AVR Programming by Elliot Williams. That book taught me the fundamentals of how microcontrollers work and how registers can be written to and read from to interact with physical circuits. When I got back to college in the Fall I begin working on this project.
The goal of the project was simple: use an accelerometer to control LED strips that ran along the bottom left and right side of my longboard. As I turned, the lights would react accordingly. I chose the ATtiny85 in the 8-pin DIP configuration. Not really sure why I chose this one other than it was small and it was cheap. At the time, I was use to writing code in Java, so 8KB of programmable flash was pretty small. Fortunately, the thing I wanted to create was also pretty small. I put a snippet of code down below so you can take a look, but the flow is pretty simple:

  1. do a little startup sequence blinking between red and blue
  2. read the ADC that’s hooked up to the accelerometer
  3. take the average ADC reading over 32 samples
  4. scale it between red and blue depending on if this is the left or right side LED controller
  5. write to the PWM pin for blue and red
  6. repeat

Looking back on projects like these I think it might be fun to go through and re-write the code. At the time I of course knew very little about C programming and was relatively new to programming in general.

Link to original

Make sure to open up the page to see the whole project.