a. Making Basic Sounds

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 11 - Audio Primitives >

a. Making Basic Sounds

This section shows how to create basic sounds using the SoundPlay() command.

 

 

Command Prototype

 

uint16_t SetSound(Sound, Pitch, Volume, Duration)

 

Parameters

Description

Sound

Type of synthesize sound

Pitch

Frequency of sound

Volume

Volume

Duration

Duration of the sound

 

 

uint16_t SoundPlay(int16_t Play)

 

Parameters

Description

Play

1 to play the sound and 0 to stop play

 

 

Code

 

 

void setup()

{

/* Initialize CleO - needs to be done only once */

 CleO.begin();

}

 

void loop()

{

/* select Sound, pitch, volume and duration */

 CleO.SetSound(CHIMES, 60, 255, 0);

 

/* play the sound */

 CleO.SoundPlay(1);

 delay(2000);

}

 

 

Description

 

The above code snippet sets the sound using the SetSound() command.

It selects the CHIMES sound with 60 pitch and 255 (Max) volume.

The SoundPlay() command is used to play the sound, where one indicates play action.

The code keeps playing this sound with a delay of  2seconds in-between.