Large Scale Central

Microcontroller powered RGB Strip lighting?

Inspired by Kevin Strong’s use of RGB LED strip lighting on his Path Valley Railroad, I started looking into sources for them. Most “kits” come with a small power supply and a controller that uses a hand held remote. That would work for me, but I’m thinking this may be my opportunity to start experimenting with microcontrollers (Raspberry Pi, etc.) to power them plus set and remember scenes. There are systems available that use a WiFi controller and a phone app to do similar, but I’d just as soon roll my own. I don’t necessarily need wireless control, but it would be OK, especially if I could just say "Hey Alexa (or Yo Google) set the railroad lighting to Late Night.

Problem is I have no idea where to begin. Anyone played around with this at all?

Not sure this counts, Jon, but I am using a RPi connected to an Arduino Uno to run a CNC router system that I am building. Its all new to me so I won’t be a lot of help, but I am interested in where this thread goes.

Jon, Check out the Wemos D1 mini. https://www.wemos.cc/ I’ve started playing with these to build my own smart/Alexa controlled light switches/outlets. https://medium.com/@monkeytypewritr/amazon-echo-esp8266-iot-a42076daafa5

The Raspberry Pi is not a microcontroller. It’s a single-board computer (SBC). A microcontroller is a microprocessor with some program memory that runs a single program over and over when you power it up, while a SBC has an operating system, file system, etc. Most SBCs run Linux, including the Raspberry Pi. To get it to do something, you need to boot it up and run a program. The SBC is much more powerful and versatile than a microcontroller, but overkill for a lot of projects. Microcontrollers boot instantly and can be turned off at any point without worry of corrupting the file system. With Linux, you have to shut down the computer when you’re done using it.

For what you’re interested in doing, I’d go for a microcontroller without a second thought. There are several, such as the one Dan linked, that have networking capabilities and other bells and whistles.

Normally, I would agree with Eric here but I just got a Raspberry Pi ZeroW for 10 bucks so I’m re-thinking my perspective. A cheap tiny computer that runs a linux operating system is pretty cool :slight_smile:

They are really cool and have a lot of great uses. I have 5 Raspberry Pis running full time doing specific tasks that are too intensive for microcontrollers But it’s a lot of overhead for a beginner, particularly for a project requiring hardware I/O!

Thanks for the suggestions guys; I’ll check that stuff out

I’m not exactly a beginner, just 25 or more years behind. My brother in-law and I were networking TRS-80 model 3 computers over an RF link (27Mhz) in 1982. I’ve done some hardware dabbling and computer programming, but it’s been a long while. I’ve played with Unix and Linux and PC OS from ROM Basic and MS DOS through Win 10. Very little on the Apple side except some 90’s hardware tech training.

Glad y’all realize I am a noob when it comes to the current crop of stuff. I been watching the SBC’s for a few years but never dug in. I’ve had microcontroller experience as an end user in several RR R/C products.

I’m thinking the microcontroller might be more suited to what I’m up to. My only problem there is programming. I’m nowhere with current languages.

The folks over at adafruit do a lot of projects controlling rgb led’s with Arduino and sell a number of strips with individually addressable led’s https://www.adafruit.com/category/168

I agree with Eric, Raspberry Pi is overkill. ESP8266 better suited for this sort of thing. BTW the Wemos D1 is $2.69 delivered. https://www.aliexpress.com/item/ESP8266-ESP12-ESP-12-WeMos-D1-Mini-WIFI-Dev-Kit-Development-Board-NodeMCU-Lua/32653918483.html

I’m like Jon, experience but it goes all the way back to CP/M, never went much beyond MS-DOS and Windows 3.1, but I am really interested in seeing what this stuff can do.

Dan Gilchrist said:

The folks over at adafruit do a lot of projects controlling rgb led’s with Arduino and sell a number of strips with individually addressable led’s https://www.adafruit.com/category/168

I agree with Eric, Raspberry Pi is overkill. ESP8266 better suited for this sort of thing. BTW the Wemos D1 is $2.69 delivered. https://www.aliexpress.com/item/ESP8266-ESP12-ESP-12-WeMos-D1-Mini-WIFI-Dev-Kit-Development-Board-NodeMCU-Lua/32653918483.html

Ooooo… That adafruit looks exactly what I’m looking for. Gonna sink some time in that website tomorrow.

On Saturday, Feb. 10, at the Bay Area Garden Railway Society (BAGRS) annual meeting (after I gave my presentation on Body Mounting Kadees) another presenter Seth Neuman, of Model Railroad Control System, described what they used (the Arduino microcontroller run with “Sketches”- a C based software so he said) along with various sensors they have.

Has anyone looked at or used any of the Model Railroad Control Systems products?

-Ted

I hadn’t thought about CP/M for years, but I was just getting nostalgic for my family’s first PC, a Kaypro II, the other day, and watching videos of it on YouTube. I was a kid in the 80s (41 now), and grew up alongside the personal computers. The Raspberry Pi really feels like going back to those days. I love the accessibility of the hardware and terminal style interface. I’m glad that kids now have something like that available. Also, being a Mac user, it’s easy to go back and forth between MacOS and Linux since they are both Unixes.

The Arduino, ESP8266, and many other microcontroller platforms are typically programmed in C++. The ++ is the object oriented capability, but if you’ve done any C programming, even 30 years ago, you’ll recognize the syntax. When I first used microcontrollers in the 90s, it was all assembly. I couldn’t believe how far things had come when I got back into it 15 years later.

I suggested the Pi Zero simply because it’s only $10. Obviously running a linux box for controlling LEDs would (normally) be overkill, but at $10, and considering the setup to get going on Ardunio, it’s a wash in my view. It also lets you program in python and has built in Wifi. So you could, in theory, setup a self contained network and web server to talk to your phone to turn your LEDs on and off. That’s pretty impressive for a board about the size of two postage stamps.

https://www.adafruit.com/product/3400

This is quite a rabbit hole. I spent 15 minutes just looking at the product page on adafruit. Need to read thier how-to pages to get a better idea of what they have going on.

I never did any programming in C. I was pretty strong in Basic before VB came along - I never made the jump to the GUI based stuff. I did some very light assembly programming back in the 80’s just to get a function I could call from Basic. I don’t even remember the project, but at the time I was running a TRS-80 Color Computer with OS9 - another Unix derivative. It’s interesting to look back now on how Multi-user was the rage then the way cloud computing is now.

Bottom line is I have the aptitude, just don’t know if I have the discipline to learn new languages. On the other hand, it looks like there is a lot of open source stuff out there and learning to modify for personal needs may not be as daunting as writing from scratch.

For your LED project, my understanding is that you need to generate 3 PWM signals - red, green, and blue - such that the duty cycle of each corresponds to the contribution of that color to the composite color you’re after. These will be logic level, so you need a transistor driver for each to interface with the strip.

To get started, once you’ve worked out the hardware, take a look at the analogwrite() function for the Arduino and other compatible platforms. https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/

Good day - I spent some time experimenting with similar LEDs and have some notes that may be of interest on my web page - there is a YouTube video, too

The LEDs that I worked with are not driven by PWM but by the Arduino sending data directly to a controller on each RGB LED - very cool technology!

Please let me know if you have any questions.

dave

http://www.trainelectronics.com/Animation-NeoPixel-LEDs/index.htm

https://www.youtube.com/watch?time_continue=1&v=q59u55Yc7XY

Thanks David - I will read your pages and check out the video. The NeoPixels products were referenced earlie They are cool - driven by a single wire data line. Each LED is uniquely addressable (https://www.largescalecentral.com/externals/tinymce/plugins/emoticons/img/smiley-surprised.gif)

After viewing David Bodnar’s video and page on the adafruit NeoPixels I think I’m just going to put a toe in the water and buy one of their smaller microcontrollers and maybe an array panel rather than a strip and start experimenting. I think I read that some of their microcontrollers have Bluetooth which interests me too for wireless remote.

But first, I need to get back to working on Martin’s beta of his Bluetooth RC/DCC locomotive control. I got a really bad idea last night while playing with it which I will share privately with Martin, but it might get me back into building electronics.

I’m about two or three videos and help pages away from pulling the trigger on some hardware to begin breadboarding some ideas. I found this nifty piece of hardware that is designed as a programming helper, but, with a few mods might be the basis for what I am after…

I envision a hardware control that has slide pots for each of 4 colors (Red Green Blue and White) allowing me to have infinitely variable light from Red through Violet plus white. I’m still in the ‘figuring this stuff out’ mode, but I am starting to get a handle on what does what and what I want.

Initially I will buy a Neopixel 8 LED RGBW strip for hardware and code development. I’m thinking about trying out the Fadecandy Controller that allows the Neopixels to be driven from any PC from a SBC to a full on desktop via USB. In the end though, I will probably end up with some type of Minicontroller. Working on a block diagram in my head to give me a better idea of the end goal. Right now I have too many conflicting ideas :slight_smile:

I have now learned enough about Neopixels to be dangerous and go over the head of many except the programmer types that hang out here. I have put some ideas down on paper so I can start working on design. This is what I have decided I want my end result to be:

Manual and Android App control of Neopixel RGBW strip lights. Neopixels are individually addressable, but for my initial purpose I will address them as parallel groups of 8. In other words, a 5 meter strip of RGBW 30 pixels/meter is about 150 modules. I’ll chop that to 144 modules, or 18 groups of 8. This will be for the purpose of what I will call Density. At 100% density all 144 pixels will be lit, or all 8 pixels of each group. At 50% density 72, or 4 pixels of every group will be lit and so on down to the last step before off which would be 18 pixels or 1 pixel per group. I am using groups since I really don’t need control of every pixel for static lighting. I may also program some of the standard effects down the road that addresses each pixel independently. I am not limiting myself to 144 pixels. I chose that as a close number to a stock length of Neopixel strip.

Color control, or what I am calling R G B & W Intensity, will be done with 4 sliders. One for each color of a pixel. The color values derived from setting the sliders will be sent to every pixel setting the brightness of each channel. For example; I could set a very washed out blue, or a very cool white by keeping the Red and Green sliders off and advancing just the Blue and White sliders. The further one advances the slider, the brighter that color becomes.

Once I have basic functionality I would like to implement pre-sets or scenes. It might be fun way down the road to just say “Alexa, set my Moonlight in Rockhill Furnace scene” and the lights come up to a pre-set color and brightness.

What I hope to achieve here is nearly infinitely variable colors and brightness. By controlling the percentage of pixels lighting up I hope to be adding steps to brightness control without affecting color. It may have a side benefit of altering the light source angle for photography. All of this remains to be seen.

When I started working out the Density steps I was surprised how quickly working with binary numbers came back to me. I can represent each of the 8 pixels in a group by one binary digit in an 8 bit byte. Full on would be all 1’s or Hexidecimal FF or 255 in Decimal. Half on of would be 10101010 or AA Hexadecimal or 170 Decimal. Part of the bread boarding task will be decide on how much resolution (how many steps) I want for density. 5 steps is pretty simple and offers some symmetry in which of the 8 pixels are lit. Maximum resolution would be 9 steps including All Off.

I’m still deciding on what hardware to buy. I’ll probably start with a simple 8 pixel strip which is all I need to develop the software. What the controller will be is still up in the air.

From the programming side I was happy to learn that the data stream for controlling Neopixels is really simple old-school logic. No protocols, just timing. The way the chip in each pixel handles the data stream is pretty cool too. It grabs the first chunk of color data, latches that then strips it from the stream and outputs the balance of the stream to the next pixel This allows each pixel to be addressed by it’s position on the strip, not be assigning it an address. Allows a bad pixel to be jumped around with no affect on the balance of the strip other than shifting everything to left by how ever many pixels are jumped out of the strip.

Seeing this from just blue LEDS has me psyched to get going…