Arduino Project: Custom Interior Lighting for Car (#1)
I've had a decent ambient lighting setup in my car for a few months (http://www.youtube.com/watch?v=Mvhj5dd1zK4). And while it looks cool, I knew I could do better. So I set out to design the ultimate lighting setup. Using an Arduino to drive the LEDs would give me ultimate flexibility, since I would be the one writing the code. If I come up with a new idea for a cool animation, I just have to write the animation and upload the new code.
In this video I walk through some of the pieces I've been working on. I'll also add some more information here that I either left out or was too boring to include in the video.
- Arduino Mega. Not much to say other than it has lots more pins than the Uno and lots more memory. Both useful characteristics for me.
- Display. The display is an OLED character display from Newhaven Displays (NHD‐0216KZW‐AB5). Similar displays have a reputation for being quite buggy when being integrated with the Arduino. What I have found is that every person who reports this tries using the display in 4-bit mode. If you hook it up with 8 data pins instead of 4, the default LiquidCrystal library works flawlessly. Once I did this, all the weird behavior was totally gone.
- Rotary Encoder (http://www.adafruit.com/products/377). The rotary encoder is a simple device that reads rotation. For each click of the rotary encoder, it reports which direction it was turned. This makes it very handy for navigating a menu. This particular encoder also has an integrated button that I use as a Select function. There are numerous cars and other devices that use this in a similar fashion.
- The LED strips are generic 12V RGB strips (http://www.adafruit.com/products/285 or http://www.adafruit.com/products/346). The Arduino only outputs 5V, however, so it cannot power these directly. Instead, the Arduino drives a set of transistors that uses the 5V from the Arduino to switch 12V to the LEDs. At this point, I have each channel (red, green, and blue) hooked to their own individual pins and use analogWrite() on those. Later on, I will likely add shift registers to expand the number of PWM outputs so I can use more channels.
Each "LED" in the strip is actually composed of three smaller LEDs: red, green, blue. By varying the amount of each color, you can vary the overall color of the strip. For example, pure red and pure blue will yield a purple color. Adding green to this mix will make the purple whiter.
As I mention in the video, humans don't think in RGB. In this video, I briefly describe the HSL color space that is a more natural mapping to describe colors. For the animations, I expect to use a mixture of both color spaces, since some effects will be easier to implement in one instead of the other.
- Parallel processing / Threading. The Arduino, like any single-core machine, is only capable of doing one thing at a time. I found a library called mthread that lets you fake it. As I mentioned, this will become extremely important because I want to be able to control each strip seemingly independently of the rest.
If you have any other questions, please ask!
In this video I walk through some of the pieces I've been working on. I'll also add some more information here that I either left out or was too boring to include in the video.
- Arduino Mega. Not much to say other than it has lots more pins than the Uno and lots more memory. Both useful characteristics for me.
- Display. The display is an OLED character display from Newhaven Displays (NHD‐0216KZW‐AB5). Similar displays have a reputation for being quite buggy when being integrated with the Arduino. What I have found is that every person who reports this tries using the display in 4-bit mode. If you hook it up with 8 data pins instead of 4, the default LiquidCrystal library works flawlessly. Once I did this, all the weird behavior was totally gone.
- Rotary Encoder (http://www.adafruit.com/products/377). The rotary encoder is a simple device that reads rotation. For each click of the rotary encoder, it reports which direction it was turned. This makes it very handy for navigating a menu. This particular encoder also has an integrated button that I use as a Select function. There are numerous cars and other devices that use this in a similar fashion.
- The LED strips are generic 12V RGB strips (http://www.adafruit.com/products/285 or http://www.adafruit.com/products/346). The Arduino only outputs 5V, however, so it cannot power these directly. Instead, the Arduino drives a set of transistors that uses the 5V from the Arduino to switch 12V to the LEDs. At this point, I have each channel (red, green, and blue) hooked to their own individual pins and use analogWrite() on those. Later on, I will likely add shift registers to expand the number of PWM outputs so I can use more channels.
Each "LED" in the strip is actually composed of three smaller LEDs: red, green, blue. By varying the amount of each color, you can vary the overall color of the strip. For example, pure red and pure blue will yield a purple color. Adding green to this mix will make the purple whiter.
As I mention in the video, humans don't think in RGB. In this video, I briefly describe the HSL color space that is a more natural mapping to describe colors. For the animations, I expect to use a mixture of both color spaces, since some effects will be easier to implement in one instead of the other.
- Parallel processing / Threading. The Arduino, like any single-core machine, is only capable of doing one thing at a time. I found a library called mthread that lets you fake it. As I mentioned, this will become extremely important because I want to be able to control each strip seemingly independently of the rest.
If you have any other questions, please ask!
- Category
- Car Projects
Comments