Do task according to pulse count or frequency
July 29, 2012
I am trying to make a program for a picaxe 20m2 chip such that it continuously counts pulses in 100 milli seconds and do specific tasks according to the no. of pulses, for ex- light an LED connected on pin b.0 for 1 second when the pulse count is 100 and light another LED which is connected to pin b.1 when the pulse count is 200. it should be like that it ''continuously monitors'' the pulses coming on one of the pins (say c.7) and do tasks accordingly but I have no idea how to do it.
Actually, i want my picaxe to respond to audio signals which contains only one single frequency (like 1000 Hz at one time) coming from a source (say a mobile phone's audio jack) and do what i have programmed it to do when it gets a particular frequency (1000Hz ---> light an LED on pin b.0).
WHAT I HAVE DID TILL NOW :-
I played a 1000 Hz tone from my phone, converted it to 5 volt digital pulses(sort of) using an op amp as they were analog audio signals (which i think can't be counted by picaxe) when they came out from my phone's audio jack, made my picaxe count those pulses using this program-
count c.7, 100, w1 ; count pulses in 100 milli secs (at 4MHz)
debug ; display value
goto main ; loop back to start
And success! (means my crappy digital pulse convertor(sort of) worked! ) It worked perfectly and it showed the value '100' in w1 in the debug window. After it, I tried 2000 Hz and it showed the value '200' indebug window.
Now i want to write a program so that it do different things on different frequencies but i don't have any idea about the code, so i want some help.
Thank you :)