Saturday, November 5, 2016

Arduino Model Railroading - Simulated Flickering Fire

Another cool exhibit on your model railroad is flickering firelight. Whether it's a hobo campfire, or a burning building, this adds to the layout's realism. A Arduino, 3 130 ohm resistors, two yellow LEDs, one red LED, and you have a fire. Add a locomotive smoke unit for additional realism. This project is provided by Mike McRoberts.


Just connect a wire from pin 9 to the resistor, from the resistor to the long leg (+) of your LED, and the short leg to Ground. Repeat for pins 10 & 11. We put the red LED on pin 10, and the 2 yellows on 9 & 11.
Code:

// LED Fire Effect

int ledPin1 = 10;
int ledPin2 = 9;
int ledPin3 = 11;

void setup()
{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}

void loop() {
analogWrite(ledPin1, random(120)+135);
analogWrite(ledPin2, random(120)+135);
analogWrite(ledPin3, random(120)+135);
delay(random(100));
}


Arduino Model Railroading - Arc Welder Flash

The guys at the Charleston Model Railroad Club asked for a simulated flash of an arc welder. A $4 (was $2.50, price went up since we purchased) arduino nano clone, a 130 ohm resistor, and a white LED later, they have their arc welder. This is a fun and inexpensive project that adds to the realism of your layout!

Project inspired by the work at http://mrrwa.org/wp-content/uploads/2011/07/ModelRailroadingWithArduino.pdf

Just connect a wire from pin 9 to the resistor, from the resistor to the long leg (+) of your LED, and the short leg to Ground.


Code:

int ledPin = 9; // LED connected to digital pin 9
int i;
int count;

void setup()
{
pinMode(ledPin, OUTPUT);
}

void loop()
{
count=random(10,60);
for (i=0;i{
digitalWrite(ledPin, HIGH); // set the LED on
delay(random(60));
digitalWrite(ledPin, LOW); // set the LED off
delay(random(200));
}
delay(random(800,2000)); // wait a random bit of time
}







Related Posts Plugin for WordPress, Blogger...