' Demo program for March 2003 SiChip PICAXE-08 article Ver 1.2 9 March 2003 ' Best assembled & tested with solderless "PICNIK" box as detailed SiChip Feb.03 ' Refer http://picaxe.orcon.net.nz for background info & potential of PICAXE-08 ' MORE RELIABLE OPERATION REPORTED FROM 5V OR LESS (4.5V ?) 6V MAY BE TOO HIGH ? ' REF http://picaxe.orcon.net.nz/optocalc.jpg for a modified calculator counter ! ' ****************************************************************************** ' Extra parts = LDR, White LED, Red LED, 2 x 100 Ohm, 1 x 330 Ohm, piezo speaker ' LDR & illuminating light can be moved apart- maybe use lenses & light guides ? ' New commands here = sound, readadc, debug, pulsout, for-next & simple maths. ' Ref.PICAXE prog.editor .pdf help files,& BASIC Stamp manuals etc for insights ' via Stan. SWAN ( MU@W, New Zealand ) => s.t.swan@massey.ac.nz <= '------------------------------------------------------------------------------- ' Byte variables b0= LDR "resistance value" b1= event counter ' b2= pulse delay in msec b3= sound loop ' Strictly only the LHS code below is needed. Remarks (') can be ignored '------------------------------------------------------------------------------- sound 4,(100,10,80,10) 'initial dual sounds to inform that powered up ldrdemo: ' LDR resistance monitoring routine readadc 1,b0 ' read LDR low resolution value via voltage divider debug b0 ' show variable LDR value(s) to attached PC screen if b0 <160 then beeper ' warbling alert tones when LDR shaded b2 = 250/b1 ' produce delay value.NB max variable value is 255 if b2 =0 then ldrdemo ' prevents LED flash when not yet triggered pulsout 2,1000 ' pulse LED pin 2 for 1000x10 microsec =10millisec pause b2:pause b2:pause b2 ' more events give decreasing delay between pulses goto ldrdemo ' continually loop unless LDR shaded beeper: ' piezo speaker 2 tone sound routine for b3= 1 to 3 ' loop to sound tones 3 times sound 4,(100,20,80,20) ' repeating dual tones each 20 msec next b3 ' sound loop increment b1=b1+1 ' event counter increment goto ldrdemo ' return to monitoring routine