Examples‎ > ‎

Example 4

These are very simple programs,  :


Very simple for loop example

CODE: simple1.bas

print "for loop example"

for z = 1 to 10
 print z * 9
next z






Simple web page with a button and a textbox.
CODE: simple2.bas

cls

tx$ = "My text"
html TextBox$(tx$) + "<br>"  + button$("My Button", jumpHere)
wait

jumpHere:
 print "You clicked. The textbox contains " + tx$
return

















Simple web page showing the temperature coming from a DS18B20.
The page is refreshed each 5 seconds
CODE: DS18B20.bas

'Simple web page showing the information
'from a DS18B20 sensor
PIN_Sensor = 2 'pin used for the DS18B20
t$ = tempr$(PIN_Sensor, 1)
onHtmlReload DoPage
gosub DoPage
timer0 5000, update
wait

DoPage:
cls
html TextBox$(t$) + " ° Celsius"
return

update:
t$ = "22" 'tempr$(PIN_Sensor, 1)
refresh
return

end






Simple web page showing the temperature and humidity coming from a DHT11.
The page is refreshed each 2 seconds
CODE: DHT11.bas

'Simple Web page showing the information
'from a DHT11 ( Temperature and Humidity)
PIN_Sensor = 2 'pin used for the DHT11
DHT.SETUP PIN_Sensor, 11
t$ = str$(DHT.Temp)
h$ = str$(DHT.HUM)
onHtmlReload DoPage
gosub DoPage
timer0 2000, update
wait

DoPage:
cls
html TextBox$(t$) + "°C<br>" + TextBox$(H$) + "%" 
return

update:
t$ = str$(DHT.Temp)
h$ = str$(DHT.HUM)
refresh
return

end