'Switchable LED or SOS flasher for Aug 2003 SiChip PICAXE-08 article V 1.0 26/6/03 'Connect 3 ultra bright white LEDs directly to PICAXE pins 4,2 & 1 + common ground. 'Switch to pin 4 may need pulldown resistor (10 k ?) since tends to float high 'Just a single LED could be used, but 3 give greater light output even though each- '-is actually lit sequentially & human "persistence of vision" perception exploited. 'Additional security results,since if 1 or 2 LEDs damaged or blown at least 1 works. 'No dropper R's as PICAXE 20mA source limit each pin is inside white LED 30mA specs. 'Extra driver transistor could be used to give ~100mA pulses?(Ref PWM "SiChip" 5/03) 'New command here =GOSUB,which allows common routine streamlining,thus memory saving. 'Maybe alter pulse duration,but 700 =7millisec seems highest flicker free pulse rate? 'Just 96 bytes used, so scope for other lighting effects- chasers/random/1-2-3 on etc 'Maybe "lost in the bush" beacon flasher once every 5 secs = prolonged battery life! '3xAA batteries (4.5V) had ~16mA max drain when pulsed ~60 hrs life (& longer on SOS) ' Via Stan. SWAN (MU@W,New Zealand) => s.t.swan@massey.ac.nz <= 'Lines beginning ' are informative program documentation & may be ignored if need be. 'Program available for web download =>www.picaxe.orcon.net.nz/ledsos.bas 'Further "08" Morse ID refinements (35 chs !)=> www.picaxe.orcon.net.nz/morse.bas '------------------------------------------------------------------------------------ ledtrio: 'routine to pulse all 3 LEDs to prolong battery life if pin3=1 then ledsos 'if pin 3 switch is low(0) just "steady" light ouput gosub pulse 'access common LED pulsed lighting routine goto ledtrio 'loop back if switch set for steady light out still '------------------------------------------------------------------------------------ ledsos: 'emergency routine to send endless SOS .../---/... for b1= 1 to 3 'morse S = dit dit dit for b0= 1 to 4 'short hold on for each "dit" element gosub pulse 'access common LED pulsed lighting routine next b0 'loop to hold on duration variable pause 200 '200ms pause between each morse element next b1 'repeat so 3 flashes generated pause 500 '1/2 sec delay between each morse character '------------------------------------------------------------------------------------ for b1= 1 to 3 'morse O = dah dah dah for b0= 1 to 15 'longer pulse hold on loop for each "dah" gosub pulse 'access common LED pulsed lighting routine next b0 'loop to hold on duration variable pause 200 '200ms pause between each morse element next b1 'repeat so 3 flashes generated pause 300 '1/2 sec (total) delay between each morse character '------------------------------------------------------------------------------------ for b1= 1 to 3 'morse S = dit dit dit for b0= 1 to 4 'short hold on for each "dit" element gosub pulse 'access common LED pulsed lighting routine next b0 'loop to hold on duration variable pause 200 '200ms pause between each morse element next b1 'repeat so 3 flashes generated pause 500 '1/2 sec delay between each morse character '------------------------------------------------------------------------------------ pause 1500 '2 second pause between SOS sending goto ledtrio 'recommence program from start '------------------------------------------------------------------------------------ pulse: 'subroutine to rapidly sequentially pulse all 3 LEDs pulsout 4,700 'pulse pin 4 700 x 10 microsecs =7000us =7ms pulsout 2,700 'pulse pin 2 (Perhaps try varying mark/space effects-) pulsout 1,700 'pulse pin 1 (using high 4:pause 5:low 4:pause 50 etc) return 'go back to program point where subroutine began