stronk_8s

IR Sensor

Nov 24th, 2025 (edited)
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | Source Code | 0 0
  1. import RPi.GPIO as IO
  2. IO.setwarning(False)
  3. IO.setmode(IO.BOARD)
  4. IO.setup(8,IO.IN)
  5. IO.setup(3,IO.OUT)
  6.  
  7. while 1:
  8.     if(IO.input(8)==True):
  9.         print("Obstacle detected!!!")
  10.         IO.output(3,True)
  11.     else:
  12.         print("Obstacle not detectedc")
  13.         IO.output(3,False)
  14.  
Advertisement
Add Comment
Please, Sign In to add comment