83Views7Replies

Author Options:

will this code work? Answered

Q1-here is the code for picaxe 08m2 will it work or something is wrong
Q2-to repeat a code what value do i have to give for the FOR loop i have assumed it to be 0 to 0

THE CODE---------

main: if pinc.4 = 1 then main2
      if pinc.0 = 1 then main3
      if pinc.1 = 1 then main4
      goto main
     
main2:for b0 = 0 to 0
      play 2,0
      next b0
      pause 2000
      goto main
     
main3:for b0 = 0 to 0
      play 2,1
      next b0
      pause 2000
      goto main     
     
main4:for b0 = 0 to 0
      play 2,3
      next b0
      pause 2000
      goto main

Tags:picaxe

Discussions

0
None
rickharris

Best Answer 7 years ago

Have you tried to run it in the simulator?

Your code runs and I can get it to play all 3 tunes so in that respect I guess it works. (simulated)

As for Q2 you don't need the for next as the tune will play a single run through once it is started automatically.

0
None
e=mc^2rickharris

Answer 7 years ago

if i dont use for next then the tune will only play when the switch is pushed but by using for next it will play by 1 switch push(as assumed by me)

0
None
rickharrise=mc^2

Answer 7 years ago

If I understand what your saying - You don't need the for next loop at all - When a switch is pressed a tune will play.

Once it is playing it will continue until the tune is finished without you doing anything.

Is that what you want it to do.

0
None
rickharrise=mc^2

Answer 7 years ago

Then that's what it does - at least in the simulator.

0
None
e=mc^2rickharris

Answer 7 years ago

can i add ir control to this circuit by modifying the program the new program is as follows
main: irin [1000,main],C.3,b0
if b0=0 then main2
if b0=1 then main3
if b0=2 then main4

if pinc.4 = 1 then main2
if pinc.0 = 1 then main3
if pinc.1 = 1 then main4
goto main

main2:for b0 = 0 to 0
play 2,0
next b0
pause 2000
goto main

main3:for b0 = 0 to 0
play 2,1
next b0
pause 2000
goto main

main4:for b0 = 0 to 0
play 2,3
next b0
pause 2000
goto main

0
None
rickharrise=mc^2

Answer 7 years ago

Assuming the commands are correct I would think so - You will have to do it and have a go - you may need to make minor alterations as you go along.