I am a new teacher trying to introduce the picaxe to my school. Currently I am trying to help an a-level student build a prototype product. I have used the picaxe years ago but I am struggling to remember and we haven't got much time. I would greatly appreciate any advice on how to make it work.
We are trying to create a switch using some LDR's which will adjust the volume of a buzzer/radio. The idea is to have a line of 3 LDR's, when the hand is stroked over them in one direction the volume goes up, in the other direction down. The script will have to identify a sequential drop in light for each LDR. I have attempted to write a script which I think is ok- Please let me know if not. I also need to find out how to include a greater margin of difference than "<" I am not sure if <b1-10 will work.
main:
readadc 1,b0
readadc 2,b1
readadc 3,b2
variable b0
if b0<b1 then loud
if b2<b1 then quiet
goto main
loud:
if b1<b0 and b1<b2 then louder
else goto main
louder:
(turn volume up gently)
if b2<b0 and b2<b1 then (turn up volume more)
else goto main
quiet:
if b1<b2 and b1<b0 then quieter
else goto main
quieter:
(turn volume down gently)
if b0<b2 and b0<b1 then (turn volume down more)
else goto main
Also how could I use it to change the volume of a radio/stereo. I will use a buzzer if it is too complicated.
We are trying to create a switch using some LDR's which will adjust the volume of a buzzer/radio. The idea is to have a line of 3 LDR's, when the hand is stroked over them in one direction the volume goes up, in the other direction down. The script will have to identify a sequential drop in light for each LDR. I have attempted to write a script which I think is ok- Please let me know if not. I also need to find out how to include a greater margin of difference than "<" I am not sure if <b1-10 will work.
main:
readadc 1,b0
readadc 2,b1
readadc 3,b2
variable b0
if b0<b1 then loud
if b2<b1 then quiet
goto main
loud:
if b1<b0 and b1<b2 then louder
else goto main
louder:
(turn volume up gently)
if b2<b0 and b2<b1 then (turn up volume more)
else goto main
quiet:
if b1<b2 and b1<b0 then quieter
else goto main
quieter:
(turn volume down gently)
if b0<b2 and b0<b1 then (turn volume down more)
else goto main
Also how could I use it to change the volume of a radio/stereo. I will use a buzzer if it is too complicated.