Hi. I am a total newbie when it comes to Arduino, although I have been a programmer for 55 years, having used Assembler, Cobol, Apple Basic, Pick Basic, Business Basic, Visual Basic, VBA, VB.Net, ASP.Net, Coldfusion, SQL / Crystal, Javascript and Jquery (not all at the same time, you understand).
My wife is into miniaturization (Adams Family Mansion, Haunted Mansion, etc.) and she needs a way of having lights turned on and off at various times. I looked into Arduino as a way of providing this, and wrote my first sketch (flashing LED) the other day. I hope to widen my knowledge as I persevere.
There's a whole shotgun of suggestions we could make, most of which will be irrelevant. Sounds like you want to do lighting animation, small scale, probably at most a few dozen LEDs at a time? Your first LED was a simple two-wire device, hopefully with a series resistance.
Two ways to go.
simply duplicate what you've done, wiring each led to an output pin from your Arduino.
Simple, straightforward, but very, very limiting.
become familiar with Neopixels and similar technology. You'll go here, whether or not you start with 1.
How many LEDs would you want to control. There’s a chip called a MAX7219 that is usually used for driving 8 7-segment LED displays or 1 8x8 dot matrix display - so 64 individual LEDs but wired up in an 8x8 matrix.
The reason I’m suggesting this device is that not only can you turn individual LEDs on or off, but the device has a test mode that turns all LEDs on and off at once - might be a useful effect. The device can also vary the brightness of all the “active” LEDs at once. You could use this feature to flash all the “active” LEDs on and off.
It might mean a fair bit of spaghetti wiring as the 8x8 LED matrix would be spread throughout the dolls house.
Another option is individually addressable LEDs so you can control the colour of them individually. I don’t have experience of using them myself so others will be better placed to advise you on the practical limits of using these in your scenario.
I would definitely look into addressable LEDs (that can display any RGB color).
Adafruit calls them “NeoPixels” and also has a well-supported library for use in Arduino. They’re also more generically known as WS281x LEDs. There are many form-factors to choose from (which is perfect for miniaturization). Having complete (and relatively simple) control over each LEDs (color/intensity) seems to fit what you’d want.
The board is a Freenove Control Board V5 Rec4 Mini. I chose it because it is cheap and I just wanted something to test my first script with. The final board will have a connection to a multiple-LED board, which (I hope) will allow me to manage a number of lights.
The final connections will be to miniature lights which come as part of the miniatures - desk light, ceiling light, carriage light, etc. I believe that these lights will be compatible with the output from the multi-LED board.
Each light will need to switch on at a set time and switch off at another time (one light's on/off times can be different to other lights' on/off times).
The on/off times and current time should be enterable from a small keyboard (?) . If a power interruption should happen, the on/off times should be accessible from the Arduino hardware (again ?), but the current time will need to be re-keyed.
I believe that all the lights are white. Even the one that is in the back of a TV is white with a translucent film in front of it. Certainly, the MAX7219 is worth looking at, although I am NOT a hardware guru. Thanks for the suggestions.
Presumably this board has a shield form-factor so will fit on top of the Freenove Control Board, and this is why you choose the Freenove Control Board.
Can the LED boards be stacked to allow multiple boards to be connected to the same Freenove Control Board?
This is for miniature buildings (dolls houses etc.). I think the "esphome" is too sophisticated, plus I'm trying to keep the cost down (and sell it at the next Miniaturization show). But thanks for the suggestion.
This is just a suggestion. If you use the ESP32C3 Super Mini, you could control the micro-house via a smartphone app. Just thinking out loud. I haven't seen any projects like this yet.
PS The Yaml language is very simple.
That's clearly not a shield form-factor and won't fit on top of your Freenove Control Board. That will make connecting the two difficult. Why did you not choose an ESP32 board that the LED board was designed for?
I'm not impressed. It has several design flaws that @ianD76 may not be aware of.
It may not be reliable. It uses 74hc04 buffer chips to boost the 3.3V outputs from an ESP32's output pins up to 5V. But the 74hc04 needs an input signal of at least 3.5V to reliably register a high signal, when powered with 5V (0.7 * Vcc according to the data sheet).
The output pins of 74hc04 can source or sink 20mA in order to drive LEDs, but the limit is 50mA per chip. If all 6 outputs were on at the same time, the current would have to be limited to around 8mA per output, hardly any more than the ESP32's own outputs. So it clearly isn't designed to drive LEDs.
@ianD76 what are the specs of the LEDs you need to drive? How much current per LED?
This is critical. Unfortunately, the tiny lights you're likely to be purchasing for buildings can come in many 'flavors', and until we know more about whatever it is you want to use, it's really difficult to give better advice.
If you want to use an MAX7219 to control individual LEDs there was a long discussion related to an analog clock using individual LEDs a few years ago. My comments start at post 13. My code is in posts 15 and 20. If interested I suggest reading the whole thread as there is a lot of useful information from me and other posters about the trade offs.
The code only sets one LED at a time. For multiple LEDs remove the code to turn off the other LEDs from
Aclock::setLed()
Add a new function patterned after setLed() to turn off an LED to give control over individual LEDs. You will also need to keep track of which LEDs are on so you can update the register correctly when turning LEDs on and off.