It wasn't too long ago that LEDs were one of the major subjects of discussion in the DCC and Electronics forum. These days there is barely a mention.
I suspect that the modeling community has learned how to work with LEDs and further detailed discussion and education is largely no longer required. My question is "why hasn't the modeling community adopted Arduino technology in the same way"?
Probably the major factor is that the Arduino circuitry and programming appears at first glance to be far more complicated than wiring up an LED. Also, I'm pretty sure that a lot of eyes glazed over once people realized that some basic programming was involved (I know mine did).
Is anyone interested in starting a thread that covers Arduino basics, and perhaps supplying a simple circuit, for example, one that turns lights on and off in various rooms at different times in a simple house? I for one would be interested
Cheers!!
Dave
I'm just a dude with a bad back having a lot of fun with model trains, and finally building a layout!
hon30critterIs anyone interested in starting a thread that covers Arduino basics, and perhaps supplying a simple circuit, for example, one that turns lights on and off in various rooms at different times in a simple house?
A modeler's introduction to the Arduino by Geoff Bunza from 2016
hon30critterI suspect that the modeling community has learned how to work with LEDs and further detailed discussion and education is largely no longer required. My question is "why hasn't the modeling community adopted Arduino technology in the same way"?
Besides driving LEDs, many modelers are using Arduinos to drive servos to control turnouts. Joe Fugate just wrote a 4 part article on Electrical Impulses: Using servos to control turnouts. I think Joe tried to present it simply for the typical modeler.
my understanding is that the vast majority of model RRs are just that modelers and not technically savy. Those who do attempt to use an Arduino have to deal both with electronics and software and suffer from common novice issues.
signalling is another common application. Randy Rinker posted code for implementing a C/MRI node compatible with JMRI. But ESP-32 boards support WiFi and can be networked wirelessly.
things like this are common on the Arduino Programming Questions Forum
what did you have in mind?
greg - Philadelphia & Reading / Reading
LED/resistor pairs can be wired between 5V and a pin.
The Arduino has 13 digital pins and 6 analog pins that can also be used to drive LEDs. Pins 0 and 1 can't be used because they are the RX and TX pins used to download code and for prints
here's code to randomly turn LEDs on/off every second. the delay is set small for testing and can easily be changed.
sorry, but the array index entryies, things inside brackets, are interpreted as
// randomly turn on/off LEDs // define an array of LED pins (pins 0 and 1 used for RX and TX) const byte PinLeds [] = { 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2 }; const int Nleds = sizeof(PinLeds); // determine # of pins in array void loop (void) { // randomly (< 10%) toggle an LED on/off for (int n = 0; n < Nleds; n++) { int r = random(10); int p = digitalRead (PinLeds); if (r < 1) digitalWrite (PinLeds, ! p); // format a parameter string char s [90]; sprintf (s, " %3d %3d %d", PinLeds, r, p); Serial.println (s); } Serial.println (); delay (1000); // wait 1 sec, 1000 milliseconds } void setup (void) { Serial.begin (9600); // initialize serial interface bit-rate // initialize each pin as an OUTPUT and randomly turn on for (int n = 0; n < Nleds; n++) { pinMode (PinLeds , OUTPUT); digitalWrite (PinLeds , random(10) < 5); } }
Hi Greg,
Thanks for the link to the Arduino website. I will have to do some reading in order to sort through the table of contents.
I guess that there is no 'two minute' shortcut. Learning Arduino programming will require a bit of a commitment.
here's a simple program that blinks the builtin LED on/off. All Arduino programs require a setup() function that is executed once and a loop() function that is executed repeatedly.
i don't know what you know so asking questions would save time
const byte PinLed = 13; void loop (void) { digitalWrite (PinLed, ! digitalRead (PinLed)); delay (1000); // wait 1 sec, 1000 milliseconds } void setup (void) { pinMode (PinLed, OUTPUT);
Greg:
What you just posted is exactly what would make my head spin.
What I would be looking for is something that said:
here is the ardino.
here is the led.
connect leads of led to A and B
connect power (x volts) to C and D
to adjust flash rate turn Y.
maxmanWhat I would be looking for is something that said:
you want a prep-programmed box with a knob on it. Is that what Dave asked for?
In my opinion, a lot of the 'action' with Arduinos in model railroading is going to involve shields and loadable code for the obvious things -- like adjustable lighting brightness control that humans familiar with dimmer knobs can actually use.
OvermodIn my opinion, a lot of the 'action' with Arduinos in model railroading is going to involve shields and loadable code for the obvious things -- like adjustable lighting brightness control that humans familiar with dimmer knobs can actually use.
that's more or less what i did for both of Daves queries above, I provided code to do what he asked. Joe Fugates article provide a basic tutorial for programming.
And what shields are needed for driving LEDs? the LED/resistor can be wired directly to the connectors on the Arduino.
it's up to the modeler to install the Arduino IDE, Integrated Development Environment, to compile and program the Arduino using a USB cable.
i recommend the mluti-function shield with the 7-segment display for experimenting with
glad to answer questions. i'm awful at guessing what they might be
why is a knob is needed for something controlling brightness, that's what the resistors are for.
My initial goal using Arduino was to animate the lighting in residential structures and commercial structures so that the lights go on and off apparently in a random sequence. I plan on doing a fair bit of night running.
I say 'apparently' because I want the majority of the building lighting to come on over a relatively short period at 'dusk', and then slowly go off in a random pattern later at night.
Obviously that will be a much more complicated scenario than a simple flashing circuit, but I will start with the simpler circuit first.
Don't expect anything soon. First I have to finish the layout room, and next would be track and DCC, and then I have to run the snow plow train.
hon30critterDon't expect anything soon.
unlike when i got started programming embedded applications using an HP64000 Workstation you can do a lot from the comfort of your couch using the Multi-function shield which has 3 buttons, 4 LEDs, connectors that are servo compatible, a pot connected to an analog input, and the 7-segment displays.
Hey HOCritter, was discussing this with a friend tonight and his comment was that using an arduino to control LEDs was akin to using a steam roller to kill an ant.
His suggestion was why not use something like thr Woodland Scenics Light Hub that can be had for about $17 list:
https://www.ebay.com/itm/384158920607?chn=ps&norover=1&mkevt=1&mkrid=711-213727-13078-0&mkcid=2&itemid=384158920607&targetid=4580909053911840&device=c&mktype=&googleloc=&poi=&campaignid=603247654&mkgroupid=1236951625700523&rlsatarget=pla-4580909053911840&abcId=9316139&merchantid=51291&msclkid=cf0f0bdc9cb91667794f6d0afa3bb735
His idea was to cut one output lead to each LED and run it to a small switch on the facia. You can use the controls on the Light Hub to vary the intensity to each group of LEDs, and use the facia switches to turn each group of LEDs on/off.
He also suggested the Woodland Scenics Sequencing Light Hub:
https://www.ebay.com/itm/285999094292?chn=ps&_trkparms=ispr%3D1&amdata=enc%3A11iZfWnbpQY2sQqgJ-adAgg4&norover=1&mkevt=1&mkrid=711-213727-13078-0&mkcid=2&itemid=285999094292&targetid=4580909052765417&device=c&mktype=&googleloc=&poi=&campaignid=603247545&mkgroupid=1236951576251627&rlsatarget=pla-4580909052765417&abcId=9316119&merchantid=51291&msclkid=dc3282168ad3133b40b8e4c0ec510a8f
This device adds a sequencing effect to the LEDs, and can be varied. And with the facia switches the different LED groups can also be manually turned on/off.
Sounds a lot less expensive than the arduino option, and no programming needs to be learned. Sounds like something even I could do.
Hi maxman,
I looked into the Woodland Scenics lighting system when it first came out. I wanted to do a fairly large urban/commercial scene and the WS system would add up pretty quickly. I felt I could scratchbuild the same thing for less money. My system will involve 200+ LEDs. A smaller scene might be more cost effective with the WS products.
hon30critterIs anyone interested in starting a thread that covers Arduino basics, and perhaps supplying a simple circuit,
of course one impedement is needing an Arduino and sufficient hardware to do something with it.
an option that requires neither is the web based wokwi.com simulator that allows you to graphically add and connect hardware, write and test the code using the simulated hardware.
doesn't require any $$ investment and no fear of damaging hardware connected incorrectly. And there's the Arduino Programming Questions forum to get help.
Thanks Greg!
hon30critterMy initial goal using Arduino was to animate the lighting in residential structures and commercial structures so that the lights go on and off apparently in a random sequence. I plan on doing a fair bit of night running.
I believe the article by Geoff Bunza referred to earlier had a program to do exactly this. p. 23, Random Building Lighting
Gary
garyaRandom Building Lighting
after seeing some of the other comments, i think what's really wanted is something that randomly turns lights on when the room light is dimmed and then randomly turns them all off when the room lights come back on.
Thanks Gary!
I really like the idea of having the structure lights come on when the light level in the room goes down.
This could get rather complex, especially in the residential buildings. Various lights could go on and off based on their locations. I believe I saw an article on this some years ago in Model Railroader.
The same idea could be applied to hotels and apartments. I'm going to have operating street lights. It would be ideal to have them controlled automatically too. Same with billboards and business signage, railroad repair shops and much more.
Doing all that wiring would be daunting but the effects would be excellent.
hon30critterI really like the idea of having the structure lights come on when the light level in the room goes down. This could get rather complex,
This could get rather complex,
when i started work in 1985, a colleague said how easy it is to implement a traffic light using a microprocessor. He neglected to consider what else could be done once a processor was used, such at optimizing traffic flow by monitoring traffic and adjusting the timing of the lights
it's trivial for an Arduino to randomly turn LEDs on/off. Adding an ambient light detector to recognize night/day isn't difficult. Outputs can easily be identified as residential or business to determine whether lights come on during the day or night or only in evening/morning.