Using Tune command with 14m

pjl83

Member
Hi,

I decided to try and play with the Tune command as I had a piezo that's been in the box for a while and never used. I wrote it into the "Win" sequence in the code below. However, when it plays in the simulator, it sets output 0 and output 2 to high? This is not good as 0 is the buzzer that sounds when you lose and 2 is one of the red led's that light when you lose.

I cant figure out why. Can anybody help?

Thanks

Code:
Main:	'the main loop
	low 4
	low 5
	low 0
	low 1
	low 2
	if pin0 = 1 then lose
	if pin1 = 1 then win
	goto main
	
lose: 'lose sequence
	pause 100
	high 0
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	pause 250
	low 1 : low 2
	pause 250
	high 1 : high 2
	low 0
	goto startagain
	
startagain:	'awaiting reset
	if pin2 = 1 then main
	goto startagain
	
win: 'win sequence
	pause 100
	high 4
	high 5
	tune 3, 5, ($75,$75,$75,$FA,$C5,$43,$42,$40,$CA,$05,$43,$42,$40,
$CA,$05,$43,$42,$43,$C0,$3C,$75,$75,$75,$FA,$C5,$43,$42,$40,$CA,
$05,$43,$42,$40,$CA,$05,$43,$42,$43,$C0)
	goto startagain
 
Last edited:

Technical

Technical Support
Staff member
Sounds like a simulator bug (or your simulation is in the wrong mode), which version PE are you using?

A real 14M will not do this.
 

westaust55

Moderator
By way of a suggestion, your "lose:" subroutine could be reduced greatly in size to:

Code:
lose:
  FOR b13 = 1 to 21
    TOGGLE 1,2
    PAUSE 250
  NEXT b13
  GOTO startagain

With regard to Settings, is the simulator set to 14M?
This can be achieved with the line in the PE program - typically at the start as:
#PICAXE 14M

or via the Options tab and select the 14M in the drop down window
 
Last edited:

Technical

Technical Support
Staff member
sequence in the code below. However, when it plays in the simulator, it sets output 0 and output 2 to high?
This is a simulation bug on output 3 only, now fixed for next release - a simple typo meant that rather than using a mask of '8' for output 3 it was using a mask of '5', which then switches 0 and 4 on instead!

The real chip will be fine.
 

pjl83

Member
Thanks for checking that out technical. Trust me to find a bug like that and get all confused.

Thanks westaust. I do have the PE set to 14m. The code tip is a good one too. Thanks.
 
Top