Simple program to sense if someone or something is near.
Uses a Sharp proximity sensor


######################################### proximity.py ###################################
# Program that uses LabJack U3 and a Sharp Proximity sensing units from All Electronics
# (Catalog number OSU-80)
# Wiring: Sharp proximity sensor's white wire connects to the LabJack U3's FIO0 connector.
# Black wire goes to ground. Red wire goes to VS (positive 5 Volts).
import u3
from easyU3 import *
from time import sleep
d = u3.U3() # Opens first found U3 over USB
u3setup(d)
print
print "Use ^C to kill this program"
while True:
#Read an analog input
ain0=analogIn0(d)
print int(5.0*ain0)*" ",
print "*",str(ain0)
sleep(0.1))

Fancier program that speaks to you and tells you to come closer…

######################################### proximity2.py ###################################
# Program that uses LabJack U3 and a Sharp Proximity sensing units from All Electronics
# (Catalog number OSU-80)
# Wiring: Sharp proximity sensor's white wire connects to the LabJack U3's FIO0 connector.
# Black wire goes to ground. Red wire goes to VS (positive 5 Volts).
def v_to_d(v):
return 60.0/v #Return the distance in centimeters
import u3
from easyU3 import *
from time import sleep
d = u3.U3() # Opens first found U3 over USB
u3setup(d)
print
print "Use ^C to kill this program"
while True:
#Read an analog input
ain0=analogIn0(d)
distance=v_to_d(ain0)
print int(distance)*" ",
print "*",str(distance)
sleep(0.1)