![Picaxe Versabot Скачать руководство пользователя страница 13](http://html1.mh-extra.com/html/picaxe/versabot/versabot_manual_1554876013.webp)
5.
Now, type the following into the text window:
symbol
IN1 = pinB.1
' Define Input P1
symbol
P2 = B.2
' Define Output P2
do
‘ Do the following ...
do while
IN1 = 1
' While the slide switch is a 1 ...
sound
P2, (100,50,110,50)
' Play two high tones
pause
500
' And delay between tones
loop
' Repeat this loop while the slide switch is 1
do while
IN1 = 0
' While the slide switch is a 0 ...
sound
P2, (50,50,60,50)
' Play two low tones
pause
500
' And delay between tones
loop
' Repeat this loop while the slide switch is 0
loop
' Repeat forever
Some things to note about the program above:
•
The
do while
command sets up a condition that while the switch is in a certain position (i.e the
1 position) a program sequence will follow. This will keep looping and will test the condition
each time before it proceeds. As soon as that condition changes (i.e. The switch is moved to
the 0 position) it will break out of the loop and continue through the code further down the
program.
•
Each
do
command has a corresponding
loop
command to show where the loop ends.
Indentation is used so each
do
command lines up with its corresponding
loop
.
•
Each
sound
command is just a two note tune in this case; more notes can be added as
required.
6. Save your program as
Buzzerprogram.bas
.
7. Press the F5 key ( or use the PICAXE/Program menu option ) to download your program into the
PICAXE on your Versabot motherboard.
8. Once the downloading has completed you can switch the slide switch back and forth to play the
two different tunes.
9. Now we can modify the above program to include a LED and a buzzer and use the switch to
interchange between the two.
Содержание Versabot
Страница 1: ...The Versabot Manual July 2009...
Страница 23: ...Step 03 Step 04 Step 05...
Страница 24: ...Step 06 Step 07 Step 08...
Страница 25: ...Step 09 Step 10 Step 11...
Страница 26: ...Step 12 Step 13...