Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Arduino Code for LED Crossing Flashers that FADE

1695 views
1 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    May 2014
  • From: Pennsylvania
  • 1,152 posts
Arduino Code for LED Crossing Flashers that FADE
Posted by Trainman440 on Monday, February 1, 2021 4:00 PM

Hi, I just got this (knockoff) arduino today, and wanted to see what I could do with it.

4 hours later (I suck at coding), I've finally written some very inefficient code for those flashing lights at crossings. Since I plan on using LEDs for my lights, they tend to just blink on and off. I wanted to recreate the fading effect, where they fade in and out intead of just blinking. And I wanted it to be controlled by a button(which Im sure you can replace with a sensor of sorts). 

The final product has a very soft fade in and fade out sequence, and also the lights dont shoot on or cut off, instead they finish the current sequence before turning off. 

Im away from all my tools and supplies, so I cobbled together some blue LEDs and manually held a wire to simulate a button. A very poor setup haha

Here's how they turned out: 

Add some sensors, maybe get some gates, and get a speaker for a bell chime and you can have a full system! 

All you need for wiring is two LEDs, a few resistors and a button.

Wire the two LEDs into pins 9 and 10 along with their given resistors. Wire the button as shown in this link: https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button

Code: https://drive.google.com/file/d/1zp54-t24x6gKOfvcwQazhVNd6Gv6WHKx/view?usp=sharing

---------------------------------------------------------------------------------------------------------------

Modeling the Santa Fe & Pennsylvania in HO

Youtube Channel: https://www.youtube.com/channel/UCLb3FRqukolAtnD1khrb6lQ

Instagram (where I share projects!): https://www.instagram.com/trainman440

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Monday, February 1, 2021 5:26 PM

Yours looks very good!

I’m working on a diorama for taking pictures and needed a crossing so I put together a pair of signals from scrap K&S brass and used a NANO as a flasher.



I used a UNO with servos for the crossing on my layout.  The Arduino FC-51 makes a good IR detector to trigger the crossing.

I just use a toggle switch for my diorama.

 

Mel



 
My Model Railroad   
http://melvineperry.blogspot.com/
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

There are no community member online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!