This function sounds one tone or a sequence of tones.

Syntax

void Sound(
  int time, 
  int vol, 
  int tone1, 
  int tone2, 
  ...
);

Parameters

time
[in] The parameter time defines the time of each tone, in steps of 20 milliseconds.
For example, time = 50 is one second.
The range of values is 1〜2,147,483,647.
The following constants are defined:
ValueDescription
0 Stop the ringing buzzer.
TCLICK Duration of 20 msec.
TSHORT Duration of 60 msec.
TSTANDARD Duration of 100 msec.
TLONG Duration of 200 msec.
TVLONG Duration of 400 msec.
ON_CONTINUOUSLY Buzzer ringing continuously.
vol
[in] The parameter vol specifies the volume.
The following values are possible:
ValueDescription
VLOW Low volume.
VSTANDARD Standard volume.
VMEDIUM Medium volume.
VHIGH High volume.
tone
[in] Specify the tone.
Contains a sequence of at most 15 tones.
The last tone should always be the value zero.
Each tone can have one of the following values:
ValueDescription
SERROR Very low error sound.
SLOW Low sound.
SMEDIUM Medium sound.
SHIGH High sound.
SPAUSE Pause of 100 msec.

Return value

None

Remarks

Program execution will continue while generating the sound sequence.
If you want to execute multiple calls to sound consecutively, or want to wait till the sound is played, use the Delay function.

Requirements

Header file:
lib.h
Library file:
libSTARTUPOPH5000.a

Sample

#include <stdio.h>
#include "lib.h"

void main(void)
{
    Sound(TCLICK,VHIGH,SERROR,SPAUSE,SLOW,SPAUSE,SMEDIUM,SPAUSE,SHIGH,0);
    Delay(TIME_100MS*40);  // Wait 4 sec 
    Delay(TIME_100MS*40);
    Sound(TLONG,VHIGH,SERROR,SPAUSE,SLOW,SPAUSE,SMEDIUM,SPAUSE,SHIGH,0);
    Delay(TIME_100MS*40);
    Sound(TVLONG,VHIGH,SERROR,SPAUSE,SLOW,SPAUSE,SMEDIUM,SPAUSE,SHIGH,0);
    Delay(TIME_100MS*40);
    for(;;);
}

Last updated: 2020/10/08