The Rain Gauge 08M Code

 

The Rain Gauge 08M Code


     #picaxe 08M

	  Symbol ThisHour = b2				; Store the current sensor count in b2
	  Symbol LastHour = b3				; Save the previous hour's count in b3

	  ;Hardware definitions

	  Symbol DataRequest = pin3
	  Symbol BucketSensor = pin4


	  setint %00010000, %00010000			; pin4 is interrupt pin
      main:
          for w0 = 1 to 60000				; Loop for 1 hour
             pause 60
          next				
          LastHour = ThisHour				; Update Last hour's count with
          ThisHour = 0					; current hour & reset current hour
		
          goto main					; Do the next hour
 
      interrupt:
          setint %00010000, %00010000			; Re-instate interrupt
 
          if DataRequest = 1 then			; Was the interrupt from the 18M2 ?
             serout 2, N2400, ("r", LastHour, ThisHour) ; Yes, so send previous hour's count & curent count.
             do : loop while DataRequest = 1		; Wait until 18M2 stops requesting before continuing
          endif
          if BucketSensor = 1 then			; Was the interrupt from the rain sensor?
             inc ThisHour				; Yes, so increment bucket-tip count
             do : loop while BucketSensor = 1		; Make sure flag has cleared sensor before continuing
          endif

          return
The Indoor Unit 18M2 Picaxe Code


This site and its contents are © Copyright 2005 - 2011 - All Rights Reserved.