Can you tell me more about the sensor? Do you have a datasheet?
If not:
- Is the sensor output digital or analogue?
--> If digital, is the sensor output high or low (digital) when it senses something?
--> If analogue, what output voltage does the sensor give when it senses something?
- Is the sensor an active or passive sensor?
--> If active, what voltage does the sensor need to work?
What you have so far looks good, except for the way you control the sensor.
TheComet

Level 91 Forumer - 9600 health, 666'666 keystroke power (*2 coffee)
Abilities: sophisticated troll, rage