Good day greetings. Tones project

elmafiax

New member
An apology had been published in another section of the forum.

Hi good day.
Greetings, I am new to this.
I need help. I am developing a project.
It is a tone system that when pressing a switch, develops a tone and when releasing it develops another tone. I have already done this, but I need that with two other switches I can select different types of tones, previously saved in the picaxe. that's where I don't know how to do it. If you can guide me how to do it, thank you in advance.


Code:

main:
let dirsC = 5
high C.1
if pinC.1=0 then
end if

high C.0
pause 500
; Please paste tune below this line...
tune 0, 1, ($52,$5C,$52)

if pinC.1=1 then

end if

high C.0

; Please paste tune below this line...
tune 0, 1, ($9C,$9C,$43,$56)

low C.0

goto main
[/ code]
 

AllyCat

Senior Member
Hi,

Welcome to the forum. To insert a program listing, put it between [code ] and [/code ] tags with NO spaces between the braces [] .

That's rather a "strange" program; you set C.1 as an output (High) and then read it with the "IF.." command. If there is a switch on that pin, then it's potentially "dangerous" (to the PICaxe) to send an output signal to it. Also, there are no instructions inside the IF ... ENDIF sections, so nothing is actually being detected. I think what you probably want to do is:
Code:
main:
   if pinC.1 = 1 then                       ; Play tune when button pulls input pin high
      tune 0, 1, ( $52,$5C,$52 )
      do : loop while pinC.1 = 1       ; Wait for button to be released
      tune 0, 1, ( $9C,$9C,$43,$56 )
   endif
   if pinC.0 = 1 then                        ; Play when another button pulls input pin high
      tune 0, 1, ( <anothertune> )
      do : loop until pinC.0 = 0         ; Wait for button to be released
      tune 0, 1, ( <anothertune> )
   endif
;  And more pins and tunes as required
goto main
You can run that in the simulator and then you'll probably want to put some PAUSEs in to make it sound better.

Cheers, Alan.
 
Top