04.03.2013 Views

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

Basic Micro Studio Syntax Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SOUND2<br />

<strong>Syntax</strong><br />

sound2 pin1\pin2,[duration\note1\note2, ...]<br />

Commands<br />

• Pin - is a variable, constant or expression that specifi es the fi rst pin used for generating note1 on.<br />

• Pin - is a variable, constant or expression that specifi es the fi rst pin used for generating note2 on.<br />

• Duration - is a variable, constant or expression that specifi es how long to play the note (following<br />

the \). Duration is in milliseconds.<br />

• Note1 - is a variable constant or expression that specifi es the fi rst frequency to generate in Hz.<br />

Notes and their duration can be a list separated by commas and only limited to the amount of<br />

user ram available.<br />

• Note2 - is a variable constant or expression that specifi es the second frequency to generate in<br />

Hz. Notes and their durations can be a list separated by commas and only limited to the amount<br />

of user ram available.<br />

Supported<br />

• BA - Supported<br />

• BAN - Supported<br />

• BAP - Supported<br />

• BAP40 - Supported<br />

Description<br />

The SOUND2 command generates two square waves. Each wave is output on a unique pin. It can<br />

drive a small piezo speaker without amplifi cation. To increase the volume output add a low pass fi lter<br />

such as a 10uf capacitor in-line.<br />

Schematic<br />

The schematic outlines a simple method of connecting a piezo speaker. The 10uf capacitor is typically<br />

an electrolytic but can be a tantalum. You can experiment by omitting the capacitor when a song is<br />

being played to see the difference it makes.<br />

P0<br />

C1<br />

10uF<br />

C2<br />

10uF<br />

Examples<br />

The following example will generate a two tone sound from P0 and P1. To connect a speaker see the<br />

circuits shown for SOUND.<br />

SPK1<br />

main<br />

sound2 p0,p1,[500\500\1000,500\600\900]<br />

goto main<br />

+<br />

-<br />

Speaker<br />

197

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!