forked from RodionGork/TinyBasic
-
Notifications
You must be signed in to change notification settings - Fork 6
example 01
Rodion Gorkovenko edited this page Feb 1, 2018
·
2 revisions
This program reads distance from HC-SR04 sensor (pin 2 trigger, pin 3 echo) and displays value on the 2-digit seven-segment LED display (6, 5 - anodes, 7...13 cathodes via 1k resistors)
1 dim a 10 b
2 data 0b0000001 0b0011111
3 data 0b0100100 0b0010100
4 data 0b0011010 0b1010000
5 data 0b1000000 0b0011101
6 data 0b0000000 0b0010000
10 gosub 100
15 if d>99; d=99
16 if d<0; d=0
20 gosub 200
30 goto 10
100 pin 3;-1
105 pin 2;1
107 d=0
110 pin 2;0
120 if !pin(3); goto 120
125 d=d+1
130 if pin(3); goto 125
135 return
200 i=d%10
202 gosub 300
205 pin 5;1
210 delay 5
215 pin 5;0
220 i=(d/10)%10
222 gosub 300
225 pin 6;1
230 delay 5
235 pin 6;0
240 return
300 x=a(i)
305 p=7
310 pin p;x%2
315 x=x/2
320 p=p+1
325 if p<14; goto 310
330 return