Thursday, July 21, 2016

Presenter / Laser pointer IOT DIY (3)

In this third article about my DIY IOT laser pointer / presenter programming examples/programming ideas to use this presenter / laser pointer.
You can also use the programs from earlier posts that i used to test the hardware with ESP8266Basic

Laser
Buzzer
DHT11
Input signals

1) Button1Laser.bas

A simple program to switch the laser on with Button1.
You need to keep the button pressed to leave the button on:

' Button1Laser.bas
cls
' Pin Laser    5 GPIO4
let PinLaser = 5

' Pin Button1 16 GPIO16
let PinButton1 = 16

html | <h1>Test Laser</h1> |
html | <br> |
html | <br>Use Button1 to control the laser<br> |
button " Exit ", [Exit]
html | <br> |
timer 1000 ,[Button1Chk]
html | <br> |

wait

[Button1Chk]
io(po,PinLaser, io(pi,PinButton1) )

wait

end

2) UseLaser.bas

This program gives a simple webpage to control the laser.
With the buttons [On] and [Off] you can switch the laser On or Off with the web interface.
The three buttons [Button1], [Reed] or [Shake] are to select other input to control the laser.

' UseLaser.bas
cls
' Pin Button1 16 GPIO16
let PinButton1 = 16

' PinLaser    5 GPIO4
let PinLaser = 5

' Pin Reed / Button4 0 GPIO0
let PinReed = 0

' Pin Shake / Button5 2 GPIO2
let PinShake = 2

u = 0

html | <h1>Select item to control the laser</h1> |

html | <br> |
button "Button1", [Button1]
html | <br> |
button "Reed", [Reed]
html | <br> |
button "Shake", [Shake]
html | <br><br> |
button "On", [On]
html | <br> |
button "Off", [Off]
html | <br><br> |
button " Exit ", [Exit]

timer 1000 ,[SetLaser]

wait

[Button1]
u = PinButton1
wait

[Reed]
u = PinReed
wait

[Shake]
u = PinShake
wait

[Off]
u = 990
wait

[On]
u = 991
wait

[SetLaser]

if u < 30 then
io(po,PinLaser, io(pi,u) )
endif

if u = 990 then
io(po,PinLaser, io(pi,0) )
endif

if u = 991 then
io(po,PinLaser, io(pi,1) )
endif
wait

end









No comments: