View Single Post
  #1   Spotlight this post!  
Unread 10-01-2002, 17:20
zorro zorro is offline
Registered User
#0292 (PantherTech)
 
Join Date: Jan 2002
Location: Kokomo, IN
Posts: 21
zorro is an unknown quantity at this point
Send a message via AIM to zorro
Auto Air Pump Code

I have seen a lot of auto air pump code out there that is longer and more sophisticated than it should be. I wrote the following code to accomplish the same task but it uses less lines of code and less IF statements. Yes, it includes a delay on turning off the pump.

Just copy and paste the following:

'=============================================
' Auto Air Pump Sub
'=============================================

' pressure is an alias for the pressure sensor
' pressure = 0 when tank is full
' pressure = 1 when tank is empty

' pump is an alias for the relay output to the pump
' When pump=1 the compressor is on.

' num_loops is a byte variable that counts loops until...
' pump_delay which is a constant for the number of loops
' to run the pressure switch after it has been
' toggled

' This code is written as a subroutine. Place the code
' after the main loop and call it by typing:
' "gosub subAutoAirPump" in the main loop

subAutoAirPump:
if (pressure = 0) then pump_check
num_loops = 0
pump = 1
return

pump_check:
if (num_loops = pump_delay) then pump_off
pump = 1
num_loops = num_loops + 1
return

pump_off:
pump = 0
return

' END CODE


Reply if you have any questions.

Greg Szorc

Last edited by zorro : 10-01-2002 at 17:23.