- Name:
- play
- Syntax:
-
PLAY pin, tune (all non-8 pin parts)
PLAY pin, tune, LED_mask (M2 parts only)
PLAY tune, LED_option (8 pin devices only)
Pin - is a variable/constant which specifies the i/o pin to use (not available on 8 pin PICAXE parts, which are fixed to using output 2).
Tune - is a variable/constant (0 - 3) which specifies which tune to play
0 - Happy Birthday 1 - Jingle Bells 2 - Silent Night 3 - Rudolph the Red Nosed Reindeer LED_mask - (M2 parts only) is a variable/constant which specifies if other PICAXE outputs (on the same port as the piezo) flash at the same time as the tune is being played. For example use %00000011 to flash output 0 and 1.
LED_option - (08M/08M2 only) is a variable/constant (0 -3) which specifies if other 8pin PICAXE outputs flash at the same time as the tune is being played.
0 - No outputs 1 - Output 0 flashes on and off 2 - Output 4 flashes on and off 3 - Output 0 and 4 flash alternately - Description:
-
Play an embedded tune out of the PICAXE output pin. PICAXE chips can play musical tones. The PICAXE is supplied with up to 4 pre- programmed internal tunes, which can be output via the play command.
To generate your own tunes use the tune command, which can play any "mobile phone" style RTTTL tune.
The PICAXE-08M has 4 internal tunes, other parts may have less. However on these other parts the 'missing' tunes (Silent Night / Rudolph etc.) are automatically downloaded via the compiler as an equivalent tune command. Therefore the play command will always work on all 4 tunes.
Effect of increased clock speed:
Parts automatically drop to 4MHz to process this command.
8-Pin Parts
Play rudolph the red nosed reindeer with output 0 flashing
- Code Example:
-
play 3,1 ; rudolph the red nosed reindeer with output 0 flashing
Copy Code Submit an Example
18M2 Example
Play rudolph the red nosed reindeer on output B.3 with B.0 and B.1 flashing
- Code Example:
-
play B.3, 1, %00000011 ; output B.3 with B.0 and B.1 flashing
Copy Code Submit an Example
Other parts
Play jingle bells on output pin 2
- Code Example:
-
play 2,1 ; jingle bells on output pin 2
Copy Code Submit an Example
Submit Your Own Code!
You must be logged in to submit code examples. Login now.