Friday, July 15, 2016

ESP8266 Basic Buzzer Tone

Today a small ESP8266 Basic program to use a Buzzer with the ESP8266 module.

The frequency of two tones can be adjusted with the two sliders
BuzTime is the time between switching to next tone
' BuzzerSiren.bas

cls
let PinBuzzer = 15
' Connect Buzzer to GND and PinBuzzer

let BuzTime = 500

let BuzV0 = 200
let BuzV1 = 300

let t = 0

html | <h1>Test Buzzer</h1> |

html | <br><br>Freq 0 |
button " 0 " , [Sliders0Off]
slider BuzV0 , 0 , 500
button "MAX" , [Slider0MAX]

html | <br><br>Freq 1 |
button " 0 " , [Sliders1Off]
slider BuzV1 , 0 , 500
button "MAX" , [Sliders1MAX]

html | <br><br> |
button " Off " , [Off]

html | <br><br><br> |
button " Exit ", [Exit]

TIMER BuzTime , [LoopPrg]

wait

[Off]
let BuzV0 = 0
let BuzV1 = 0
wait

[Slider0MAX]
let BuzV0 = 500
wait

[Slider0Off]
let BuzV0 = 0
wait


[Slider1MAX]
let BuzV1 = 500
wait

[Slider1Off]
let BuzV1 = 0
wait

[LoopPrg]

if t = 0 then
io(pwo,PinBuzzer,BuzV0)
endif

if t = 1 then
io(pwo,PinBuzzer,BuzV1)
endif

t = t + 1
if t > 1 then
t = 0
endif

wait

[Exit]
io(pwo,PinBuzzer,0)
cls

end


The picture in this post is of a project
is a sneak preview form a project that i want
to publish next week on this blog.
As you perhaps can see it includes a buzzer and
 a ESP8266 and this program will run on it.

No comments: