BASIC

Here’s a sample of the code used to program the microcontroller.

‘ {$STAMP BS2}
‘ {$PBASIC 2.0}

‘This program is for the frequency of the 6 strings of a normally tuned guitar
‘E – 82.4
‘A – 110
‘D – 146.8
‘G – 196
‘B – 246.9
‘E – 329.6

FREQOUT 10, 5000, 82
PAUSE 250
FREQOUT 10, 5000, 110
PAUSE 250
FREQOUT 10, 5000, 147
PAUSE 250
FREQOUT 10, 5000, 196
PAUSE 250
FREQOUT 10, 5000, 247
PAUSE 250
FREQOUT 10, 5000, 330

     That’s a pretty self-explanatory program. It sounds terrible on the piezo buzzer I have. Each part of the commands is pretty simple. The ‘frequout’ outputs a frequency. The first number is the pin number the output goes to. The second number is the length that the tone plays for, in milliseconds. And the third number is the frequency, in Hertz. Alas, the language doesn’t recognize decimal frequencies, so I can’t get the exact tone output. ‘Pause’ pauses for the number in milliseconds. I also added an LED for light output with the sound, just to play around a little.

Advertisements

One thought on “BASIC

  1. Pingback: My HTML Tutorial: Part 1 | Jeremy's Random Adventures

Any thoughts? I'd like to hear from you!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: