A while ago I designed some model aircraft lights that creates the rotating beacon, strobes, navigation lights and landing lights. They can be switched with a spare channel from a RC receiver. It is intended for Attiny85, but also works on other Arduino's.
I poked the leds through a picture of a plane, to show the effect.
There is a long thread about developing it on this forum, but it is in Dutch. And there is a PCB now.
You can load this in your Arduino and you will see the rotating beacon on Arduino pin 6.
// constants won't change. Used here to set pin numbers:
const int beacon_led = 6; // Rotationg Beacon, select a PWM ~ capable pin !!
const int strobe_led = 5; // Strobe pulselight
const int landinglight_led = 4; // Landing Light
const int navigation_led = 2; // Navigation lights
const int servo = 3; // Servo input
//*************** ONLY CUSTOMIZE THESE 2 VALUES BELOW *********************************
long beacon_interval = 1000; // loop duration for the beacon to make 1/2 revolution
long strobe_interval = 1000; // loop duration for the interval between strobe sequence
// value is in milliseconds, so with the default 1000 this is one revolution per 2 seconds for
// the beacon and one series of strobe flashes per second
//*************** ONLY CUSTOMIZE THESE 2 VALUES ABOVE *********************************
// Variables that will change:
int ledState = LOW; // ledState used to set the LED
long currentMillis; // time the system is on since power-up
long previous_beacon_Millis = 0;// will store last time beacon was at high or low
long previous_strobe_Millis = 0;// will store last time strobe sequence started
long beacon_timer = 0; // time within one beacon loop
long strobe_timer = 0; // time within one strobe loop
int brightness = 0; // how bright the LED is
int updown = 1; // Slow led beacon increasing or decreasing
int ch1; // servo input channel value
int lighton = 1;
int landing = 1;
void setup() {
// set the digital pin as output:
pinMode(beacon_led, OUTPUT);
pinMode(strobe_led, OUTPUT);
pinMode(landinglight_led, OUTPUT);
pinMode(navigation_led, OUTPUT);
pinMode(servo, INPUT_PULLUP); // Set servo channel input
}
void loop() {
// check to see if the beacon loop interval has passed and need to restart
currentMillis = millis();
if (currentMillis - previous_strobe_Millis > strobe_interval) previous_strobe_Millis = currentMillis;
if (currentMillis - previous_beacon_Millis > beacon_interval) {
previous_beacon_Millis = currentMillis;
updown = - updown;
ch1 = pulseIn(servo, HIGH, 25000); // Read the pulse width of servo signal connected to pin D3
if ((map(ch1, 1000, 2000, -500, 500)) < 200) lighton = 1;
else lighton = 0 ;
if ((map(ch1, 1000, 2000, -500, 500)) < -200) landing = 1;
else landing = 0 ;
}
beacon_timer = currentMillis - previous_beacon_Millis; // calculate milliseconds within beacon loop
strobe_timer = currentMillis - previous_strobe_Millis; // calculate milliseconds within strobe loop
if (lighton == 1) {
digitalWrite(navigation_led, HIGH);
// depending on how far we are in the loop, led's are switched on or off.
if (strobe_timer > 000 && strobe_timer < 101) digitalWrite(strobe_led, LOW);
if (strobe_timer > 100 && strobe_timer < 126) digitalWrite(strobe_led, HIGH);
if (strobe_timer > 125 && strobe_timer < 201) digitalWrite(strobe_led, LOW);
if (strobe_timer > 200 && strobe_timer < 226) digitalWrite(strobe_led, HIGH);
if (strobe_timer > 225 && strobe_timer < 301) digitalWrite(strobe_led, LOW);
if (strobe_timer > 300 && strobe_timer < 326) digitalWrite(strobe_led, HIGH);
if (strobe_timer > 325 && strobe_timer < 401) digitalWrite(strobe_led, LOW);
if (updown == 1) {
brightness = map(beacon_timer, 0, beacon_interval, 1, 255);
}
else {
brightness = map(beacon_timer, 0, beacon_interval, 255, 1);
}
analogWrite(beacon_led, (255 / brightness));
digitalWrite(landinglight_led, landing);
}
else {
analogWrite(beacon_led, 0);
digitalWrite(strobe_led, LOW);
digitalWrite(landinglight_led, LOW);
digitalWrite(navigation_led, LOW);
}
}
The formula for the rotating beacon is to have a brightness counter upcounting (0-255) and then downcounting (255-0) and then use a division to get the brightness spike. analogWrite(beacon_led, (255 / brightness));
Good luck!