08M2 welder flicker simulation

gran_dad

New Member
Hi all,
Well I'm sure others have done this, but here is my two pennuth.
I wanted to simulate the flicker of a welding torch / mig welder for our garden railway layout.
So using ultra-bright blue and white LEDs I wrote this simplistic program.

Code:
'  This program runs on a PICAXE-08M2.
'  Used to flicker LEDs on pin 5 & 7
'  to simulate welding flicker
'  Wire white LED from pin 5 to ground via suitable resistor
'  Wire blue LED from pin 7 to ground via a suitable resistor
'  I used 220R resistors in both cases.
'  The original 'tune' was The Magic Roundabout theme ring tone!!


' === Directives ===
#picaxe 08M2       ' specify processor

w0=0
w1=0
' ============= Begin Main Program =============
do
	random w0
	let w1 = b0*21
	tune 3, 2,($27,$67,$67,$22,$22,$24,$64,$64,$20,$20,$25,$65,$65,$20,$20,$26,$66)
	pause w1
	
	random w0
	let w1 = b0*25
	tune 3, 2,($27,$67,$67,$22,$22,$24,$64)
	pause w1
	
	random w0
	let w1 = b0*19
	tune 3, 2,($27,$67,$67,$22,$22,$24,$64,$64,$20,$20,$25)
	pause w1	
 
loop	'carry on indefinately
end
I am pleased with the effect it creates :rolleyes:, YMMD

Martin
 

binary1248

Senior Member
Cobbled this together and it works great. Don't understand the 'Tune' command, fist argument is '3', supposed to refer to pin output, but the outputs are on physical pins 5 and 7 (c.2 & c.0 on 08M2) so what does the 3 stand for.
At anyrate this is great for my son-in-laws HO train layout.
 

hippy

Technical Support
Staff member
The TUNE command has differing formats and varying functionality depending on which chip is being used. For an 08M2 the first number is a 'LED mask' which indicates which pins to flash and/or flicker; both C.0 and C.4 in this case -

http://www.picaxe.com/BASIC-Commands/Digital-InputOutput/tune

The TUNE outputs tones to the LED on C.2, and also flashes the other LED on C.0.
 
Top