Another Prop Controlled LED RC Airplane
This is the third RC plane I've put LEDs on. I've learned from my last two airplanes that I only need a few LEDs to be able to fly but more LEDs is a real crowd pleaser. As inclined as I am to please people, none of these people carry spare LiPos and if they did probably have the wrong connector. So how can I minimize the number of LEDs to get more flight time, but also not let our audience down?
Add a microcontroller. I can make some lights blink, which not only makes up for lack of LEDs but also cuts down on power as well
[video=youtube_share;_SwmvyhGOBQ]
Add a microcontroller. I can make some lights blink, which not only makes up for lack of LEDs but also cuts down on power as well
[video=youtube_share;_SwmvyhGOBQ]

{{
Airplane Anti-Collision, Position, and Nav light testing
}}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
BLED = 2 'Pin of Blue Canopy LED
STR = 1 'Pin of thy Strobe Lights
VAR
long beacons [100] 'stack space
long strobess [100] 'stack space
long BLEDi
PUB main
dira[BLED] := 1 'enable output on blue LED pin
dira[STR] := 1 'enable output on strobes pin
cognew(beacon, @beacons) 'start a cog to run the blue beacon
cognew(strobes, @strobess) 'start a cog to run the strobes
PUB beacon
dira[BLED] := 1 'enable output on blue LED pin
BLEDi := 10 'sets the initial brightness percentage at 10%
repeat
repeat until BLEDi == 20 'get brighter
CTRA := %0_0110<<26 + BLED
FRQA := $7FFF_FFFF/50 * BLEDi
BLEDi := BLEDi + 1
waitcnt(clkfreq / 20 + cnt)
repeat until BLEDi == 5 'get dimmer
CTRA := %0_0110<<26 + BLED
FRQA := $7FFF_FFFF/50 * BLEDi
BLEDi := BLEDi - 1
waitcnt(clkfreq / 20 + cnt)
PUB strobes
dira[STR] := 1 'enable output on strobes pin
repeat 'strobe blink pattern
outa[STR] := 1
waitcnt(clkfreq / 15 + cnt)
outa[STR] := 0
waitcnt(clkfreq / 15 + cnt)
outa[STR] := 1
waitcnt(clkfreq / 15 + cnt)
outa[STR] := 0
waitcnt(clkfreq / 15 + cnt)
outa[STR] := 1
waitcnt(clkfreq / 15 + cnt)
outa[STR] := 0
waitcnt(clkfreq / 15 + cnt)
outa[STR] := 1
waitcnt(clkfreq / 15 + cnt)
outa[STR] := 0
waitcnt(clkfreq * 2 + cnt)


Comments
Nothing like a good field test.
I made it only three channel using NPNs to allow Vin to pass through the headers. Even though I cut the board in half I still have access to pins 0 through 21, which for this project I doubt I'll use. I added a fuse to the other side of the JST, and the three channel flashing LEDs are independent of the always on LEDs as well.
For the price of the Project Board and the work involved it blows away purchasing some of the controllers I've seen. There's a ton of room to expand as well, but I don't need to on this airplane at all.
For the blue LED in the center I'm going to have that blink different patterns based on how long the system has been on which should make a good battery timer.
The strobes blink a couple different patterns as well.
{{ 3 Channel LED Controller for LEDs }} CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 BLED = 0 'Pin of blue canopy LED LSTR = 5 'Pin of left LED wing strobe RSTR = 4 'Pin of right LED wing strobe VAR long beacons [100] 'stack space long strobess [100] 'stack space long time PUB main cognew(beacon, @beacons) 'start a cog - blue beacon of time keeping cognew(strobes, @strobess) 'start a cog - strobes of awesomeness PUB beacon dira[BLED] := 1 'enable output on blue LED pin waitcnt(clkfreq * 60 + cnt) 'offset the timer by one minute time := 0 'reset timer repeat until time == 180 'blink blue LED slow pattern outa[BLED] := 1 waitcnt(clkfreq * 3 + cnt) outa[BLED] := 0 waitcnt(clkfreq * 1 + cnt) time := time + 4 repeat until time == 360 'blink blue LED medium pattern outa[BLED] := 1 waitcnt(clkfreq * 2 + cnt) outa[BLED] := 0 waitcnt(clkfreq * 1 + cnt) time := time + 3 repeat until time == 540 'blink blue LED fast pattern outa[BLED] := 1 waitcnt(clkfreq * 1 + cnt) outa[BLED] := 0 waitcnt(clkfreq * 1 + cnt) time := time + 2 outa[BLED] := 0 'blue LED off at 9 minutes + timer offset PUB strobes dira[LSTR] := 1 'enable output on strobes pin dira[RSTR] := 1 'enable output on strobes pin repeat 'regular strobe blink pattern outa[LSTR] := 1 outa[RSTR] := 1 waitcnt(clkfreq / 15 + cnt) outa[LSTR] := 0 outa[RSTR] := 0 waitcnt(clkfreq / 15 + cnt) outa[LSTR] := 1 outa[RSTR] := 1 waitcnt(clkfreq / 15 + cnt) outa[LSTR] := 0 outa[RSTR] := 0 waitcnt(clkfreq / 15 + cnt) outa[LSTR] := 1 outa[RSTR] := 1 waitcnt(clkfreq / 15 + cnt) outa[LSTR] := 0 outa[RSTR] := 0 waitcnt(clkfreq / 15 + cnt) outa[LSTR] := 1 outa[RSTR] := 1 waitcnt(clkfreq / 15 + cnt) outa[LSTR] := 0 outa[RSTR] := 0 waitcnt(clkfreq * 1 + cnt) outa[LSTR] := 1 'alternate strobe blink pattern outa[RSTR] := 0 waitcnt(clkfreq / 2 + cnt) outa[LSTR] := 0 outa[RSTR] := 1 waitcnt(clkfreq / 2 + cnt) outa[LSTR] := 1 outa[RSTR] := 0 waitcnt(clkfreq / 2 + cnt) outa[LSTR] := 0 outa[RSTR] := 1 waitcnt(clkfreq / 2 + cnt) outa[LSTR] := 1 outa[RSTR] := 0 waitcnt(clkfreq / 2 + cnt) outa[LSTR] := 0 outa[RSTR] := 1 waitcnt(clkfreq / 2 + cnt) outa[LSTR] := 1 outa[RSTR] := 0 waitcnt(clkfreq / 2 + cnt) outa[LSTR] := 0 outa[RSTR] := 1 waitcnt(clkfreq / 2 + cnt) outa[RSTR] := 0 waitcnt(clkfreq* 1 + cnt) outa[LSTR] := 1 'both on for one second outa[RSTR] := 1 waitcnt(clkfreq * 1 + cnt) outa[LSTR] := 0 'both off for one second outa[RSTR] := 0 waitcnt(clkfreq * 1 + cnt)