This example of digital output uses a buzzer to generate the alarm sound of a clock. It can be managed from the Internet via alarmOn and alarmOff commands.
Connect the buzzer as shown in figure 1:
The long PIN is positive.
Write a sketch K to define:
buz :: d2beep = [buz=!buz ^8] alarmOn = [beep #3]alarmOff = [beep #0, buz=0]or simply load the sketch with the command
] load e02_buzzerTry the following commands now:
] beepthe buzzer emits 4 beeps (buz=!buz ^8 switches buz 8 times every tenth of a second)
] alarmOnthe buzzer emits 4 beeps every 3 seconds
] ??--- Periodic commandsbeep #3shows the periodic commands running
] alarmOffthe buzzer does not emit any beeps
] ??nullthe periodic command beep #3 was deleted
] alarmOn ##30sets a 30-second timer (wait for 30 seconds to hear the alarm).
In this lesson you learned or repeated: