Hi all,
First attempts with a picaxe and starting to develop some code. this code is nowhere near complete but a working model that I am running through simulate.
Subroutine noise calls 2 other subroutines, the first one, setthresh, works fine and the return goes back to noise however noise then calls setdelay but the return here jumps to setthresh instead of noise where it was called from.
I can't understand why this is happening, to my, thinking the return in setdelay should go back to the point in noise where it was called from. or am I barking up the wrong tree?
Programming editor 5.3.1
P.S any valid critiques of the code so far also welcome.
First attempts with a picaxe and starting to develop some code. this code is nowhere near complete but a working model that I am running through simulate.
Subroutine noise calls 2 other subroutines, the first one, setthresh, works fine and the return goes back to noise however noise then calls setdelay but the return here jumps to setthresh instead of noise where it was called from.
I can't understand why this is happening, to my, thinking the return in setdelay should go back to the point in noise where it was called from. or am I barking up the wrong tree?
Programming editor 5.3.1
P.S any valid critiques of the code so far also welcome.
Code:
; Camera Thingy fire flash on various inputs and Intervalometer
; V1
;Define symbols for input and output pins
symbol LEDShutter = b.0
symbol LEDFlash = b.1
symbol Focus = b.2
symbol Shutter = b.3
symbol Flash1 = b.4
symbol Flash2 = b.5
symbol FlashHV = b.6
symbol Unused = b.7
symbol Sensor1 = c.0
symbol Sensor2 = c.1
symbol LCD = c.2
symbol ButtonSET = pinc.5
symbol ButtonUP = pinc.6
symbol ButtonDOWN = pinc.7
;Define Symbols to control Outputs
symbol AllOff = %00000000 ;All Outputs Off
symbol FireFocus = %00000100 ;Focus On
symbol FireShutter = %00001101 ;Focus, Shutter & LEDShutter On
symbol FireFlash = %01111111 ;Focus, Shutter, Both LEDs and all Flash On
;Define Variables
symbol Threshold = b0 ;Threshold for microphone trigger (0-255) Check figures for sensitivity
symbol Delay = b1 ;Delay before firing flash (maybe needs to be a word)
;Setup input and Outpit pins
let dirsb = %11111111 ;All B pins set as Output
let dirsc = %00000100 ;All C pins as Input except c.2 output for LCD
pause 1000
serout LCD,N2400,(254,128," The ")
serout LCD,N2400,(254,192," Camera Thingy ")
pause 1000
main:
serout LCD,N2400,(254,128,"Sound Activated ")
if buttonset = 1 then goto noise ;add other menu options here
pause 10 ;Debounce?
goto main
noise:
serout LCD,N2400,(254,128," Sound Sensor ")
gosub setthresh
gosub setdelay
setthresh:
serout LCD,N2400,(254,192,"Threshold = ",#Threshold," ")
if buttonup = 1 then
inc threshold
else if buttondown = 1 then
dec threshold
else if buttonset = 1 then
return
endif
pause 10 ;delay needed for debounce?
goto setthresh
setdelay:
delay = 0
return
Attachments
-
1.7 KB Views: 2
Last edited: