REM Counter Meter REM Count the number of turn of Picobot running REM Use simple ON/OFF sensor REM Maximum 9999 SetPin gp0, dout SetPin gp1, dout SetPin gp2, dout SetPin gp3, dout SetPin gp4, dout SetPin gp5, dout SetPin gp6, dout SetPin gp12,dout SetPin gp13,dout SetPin gp14, dout SetPin gp15, dout Sub led1 d Pin(gp12)=0 : Pin(gp13)=1 : Pin(gp14)=1 : Pin(gp15)=1 Write_segment d End Sub Sub led2 d Pin(gp12)=1 : Pin(gp13)=0 : Pin(gp14)=1 : Pin(gp15)=1 Write_segment d End Sub Sub led3 d Pin(gp12)=1 : Pin(gp13)=1 : Pin(gp14)=0 : Pin(gp15)=1 Write_segment d End Sub Sub led4 d Pin(gp12)=1 : Pin(gp13)=1 : Pin(gp14)=1 : Pin(gp15)=0 Write_segment d End Sub Sub write_segment d Select Case d Case 0 Pin(gp0)=0: Pin(gp1)=0:Pin(gp2)=0: Pin(gp3)=0 Pin(gp4)=0:Pin(gp5)=0: Pin(gp6)=1 Case 1 Pin(gp0)=1: Pin(gp1)=0:Pin(gp2)=0: Pin(gp3)=1 Pin(gp4)=1:Pin(gp5)=1: Pin(gp6)=1 Case 2 Pin(gp0)=0: Pin(gp1)=0:Pin(gp2)=1: Pin(gp3)=0 Pin(gp4)=0:Pin(gp5)=1: Pin(gp6)=0 Case 3 Pin(gp0)=0: Pin(gp1)=0:Pin(gp2)=0: Pin(gp3)=0 Pin(gp4)=1:Pin(gp5)=1: Pin(gp6)=0 Case 4 Pin(gp0)=1: Pin(gp1)=0:Pin(gp2)=0: Pin(gp3)=1 Pin(gp4)=1:Pin(gp5)=0: Pin(gp6)=0 Case 5 Pin(gp0)=0: Pin(gp1)=1:Pin(gp2)=0: Pin(gp3)=0 Pin(gp4)=1:Pin(gp5)=0: Pin(gp6)=0 Case 6 Pin(gp0)=0: Pin(gp1)=1:Pin(gp2)=0: Pin(gp3)=0 Pin(gp4)=0:Pin(gp5)=0: Pin(gp6)=0 Case 7 Pin(gp0)=0: Pin(gp1)=0:Pin(gp2)=0: Pin(gp3)=1 Pin(gp4)=1:Pin(gp5)=1: Pin(gp6)=1 Case 8 Pin(gp0)=0: Pin(gp1)=0:Pin(gp2)=0: Pin(gp3)=0 Pin(gp4)=0:Pin(gp5)=0: Pin(gp6)=0 Case 9 Pin(gp0)=0: Pin(gp1)=0:Pin(gp2)=0: Pin(gp3)=0 Pin(gp4)=1:Pin(gp5)=0: Pin(gp6)=0 End Select End Sub Sub turn_off_display Pin(gp0)=1: Pin(gp1)=1:Pin(gp2)=1: Pin(gp3)=1 Pin(gp4)=1:Pin(gp5)=1: Pin(gp6)=1 Pin(gp12)=1 : Pin(gp13)=1 : Pin(gp14)=1 : Pin(gp15)=1 Pause (1) End Sub Sub scan a,b,c,d led1 a Pause (0.1): turn_off_display led2 b Pause (0.1): turn_off_display led3 c Pause (0.1): turn_off_display led4 d Pause (0.1): turn_off_display End Sub SetPin gp8, din n=0 Do 'f = Pin(gp8)*60/20 ' compute rmp using TT motor 20 slots disc 'f = Pin(gp8) ' count pulse input If Pin(gp8)=1 Then n=n+1 : Print n : Pause 500 m=n i = n\1000 n = n Mod 1000 j = n\100 n = n Mod 100 k = n\10 l = n Mod 10 n=m 'Print i,j,k,l scan i,j,k,l 'scan 1,2,3,4 Pause (5) Loop