; Keith Blanding ; NOW *six* photo censors running *six* relays/electronic devices ; working now, finally (April 14th 2007) UPDATED April 18th ; thanks to all who helped to sensor1 . ifelse ((read-ad 0) < 700) [setbit 7 portb] [clearbit 7 portb] end to sensor2 . ifelse ((read-ad 1) < 700) [setbit 6 portb] [clearbit 6 portb] end to sensor3 . ifelse ((read-ad 2) < 700) [setbit 5 portb] [clearbit 5 portb] end to sensor4 . ifelse ((read-ad 3) < 700) [setbit 4 portb] [clearbit 4 portb] end to sensor5 . ifelse ((read-ad 4) < 700) [setbit 3 portb] [clearbit 3 portb] end to sensor6 . ifelse ((read-ad 5) < 700) [setbit 2 portb] [clearbit 2 portb] end to run_sensors . loop [ . sensor1 wait 2 . sensor2 wait 2 . sensor3 wait 2 . sensor4 wait 2 . sensor5 wait 2 . sensor6 wait 2 . ] end to init-all . write porta-ddr #111111 ;make A0-A5 inputs . write portb-ddr #000000 ;make B2-B7 outputs end to powerup . init-all . clearbit 2 portb ;make sure they are off to start with . clearbit 3 portb ;make sure they are off to start with . clearbit 4 portb ;make sure they are off to start with . clearbit 5 portb ;make sure they are off to start with . clearbit 6 portb ;make sure they are off to start with . clearbit 7 portb ;make sure they are off to start with end to startup . run_sensors end
