Use of the RTC for Controlling Periodic Events


' Periodic.Bas
'
' Flashes an LED on Pin 4 rapidly for 10 seconds and then slowly
' for five seconds.
'
' This concept might be extended to such periodic tasks as turning on 
' a sprinkler for an hour every 6 hours.
'
' Copyright, Onya Barnes, Baltimore, MD, Oct, '99

Public Sub Main()

  Dim elaspe_time as single
  Dim hour as byte
  Dim minute as byte
  Dim second as single
  Dim test_1 as string
  Dim test_2 as string

  Call OpenSerialport(2, 9600)		
  Call PutTime(0, 0, 0.0)
  
  Do
     Call GetTime(hour, minute, second)
     elaspe_time=3600.0*CSng(hour) + 60.0*CSng(minute) + second		
   	            
     If ( (elaspe_time) <= 10.0 ) Then	' fast flash for 10 secs
	Call PutPin(4, 0)
	Call Sleep(0.05)		
        Call PutPin(4, 1)
        Call Sleep(0.05)
     ElseIf (elaspe_time> 10.0) And (elaspe_time <= 15.0) Then 
			' slow flash for 5 seconds
	Call PutPin(4, 1)
	Call Sleep(0.5)
        Call PutPin(4, 0)
        Call Sleep(0.5)
     Else
	Call PutTime(0,0, 0.0)
     End If
   Loop
			
End Sub