If you are not familiar with basic programming of micro-controllers, I strongly suggest you get yourself an adafruit trinket, read the directions on adafruit website, and a test board and teach yourself a bit about programming with the arduino IDE. It takes a bit of time to get the hang of basic programming, but once you have it, for a few $'s, you can control innumerable lights, sounds, stepper motors, etc. I also taught myself to program a 2$ WT588D sound board via/SPI flash plug-in. Both of these use free IDE's. The WT588D can hold hundreds of sounds and can be triggered via serial interface or mechanical switch. I am using one for the fog horn via a red button mechanical switch. Board comes with built-in 2w amp!
Anyway, below is a pic of an Adafruit trinket (7$). I have programmed it to flash the two masthead lights ON 2 sec, OFF 1 sec, On 2 sec, OFF 3 sec. I could run the lights directly off the board, but instead, I am using x2 3904 NPN transitors (100 for 7$!).
Here is the program, so you can see how it looks. I have it set so that when I power +3.7v to pin 4, the masthead lights will flash. Have to define pins differently, hence LED and LIGHT. Could define them as fore and aft, just have to describe them the same throughout the program. What is nice is that I can #define 'X' as pin 1,2,3,4, and it will follow through the program. That is nice and easy. I could probably get rid of the excess brackets {} in the loop, but I wanted to define each action as it follows the previous action. This program takes 17% of the trinket memory. Another program I wrote takes 97% and does a whole lot more!
As with most small microprocessors, they are made to run one program from beginning to end, unless you ad a bunch of if/then statements. If you keep the program short and sweet, the trinket can nearly instantaneously run what seems like several different programs at once. Or spend 12$ and get a larger processor! For example, there is a simple mathematical formula for my void loop to blink lights, and which could be written as one line. But since what I have below works great and is easily configured to add or take time away, I chose this method.
#define LED 3
#define LIGHT 2
#define BUTTON 4
void setup()
{
pinMode (LED, OUTPUT);
pinMode (LIGHT, OUTPUT);
pinMode (BUTTON, INPUT);
}
void loop()
{
if (digitalRead(BUTTON));
{
{
digitalWrite(LED , HIGH);
digitalWrite(LIGHT, LOW);
delay(2000);
}
{
digitalWrite(LED , LOW);
digitalWrite(LIGHT, LOW);
delay(1000);
}
{
digitalWrite(LED , LOW);
digitalWrite(LIGHT, HIGH);
delay(2000);
}
{
digitalWrite(LED , LOW);
digitalWrite(LIGHT, LOW);
delay(3000);
}
}
}