Marker Lamp 2015.08
// Arc welder routine for an Arduino board
// Flashes the on-board LED attached to digital pin 13
// in a random pattern similar to an arc welder
// To use a different pin change the pinMode and digitalWrite
// lines to the pin you wish to use
// Programmed by Rick Jones and released for public use
// by the model railroading community
// Adding random wait after welding a random number of cycles
// by Gert Muller
// this function tuns only at power up
void setup() {
pinMode( 13, OUTPUT ); // set digital pin 13 as an output,
// the on-board LED is connected to it
} // setup
// this function runs over and over, until power down
void loop() {
int j = random( 0, 100 ); // welding for a random number of cycles
// so i is now a random number between
// -1 and 100, see
// https://www.arduino.cc/en/reference/random
while ( j > 0 ) {
digitalWrite( 13, HIGH ); // LED is on...
delay( random( 0, 100 ) ); // ...for a random number of
// milliseconds between -1 and 100
digitalWrite( 13, LOW ); // LED is then turned off...
delay( random( 0, 100 ) ); // ...for another randomly chosen
// interval between -1 and 100 milliseconds
j--; // reduce j by one, same as j = j - 1;
} // while j
j = random( 0, 8000 ); // now pick a new random number of milliseconds
delay( j ); // and stay off, you need to move to another spot to weld
} // loop