Guest User

Untitled

a guest
May 22nd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. pi@raspberrypi:~ $ vi peter.py
  2. pi@raspberrypi:~ $ sudo python2 peter.py
  3. Traceback (most recent call last):
  4. File "peter.py", line 22, in <module>
  5. if current_state2(TRUE) and current_state(FALSE) != previous_state2(FALSE) and previous_state(FALSE):
  6. NameError: name 'TRUE' is not defined
  7.  
  8.  
  9.  
  10. import RPi.GPIO as GPIO
  11. import time
  12.  
  13. sensor = 4
  14. sensor2 = 17
  15. GPIO.setmode(GPIO.BCM)
  16. GPIO.setup(sensor, GPIO.IN, GPIO.PUD_DOWN)
  17. GPIO.setup(sensor2, GPIO.IN, GPIO.PUD_DOWN)
  18.  
  19. previous_state = False
  20. current_state = False
  21.  
  22. previous_state2 = False
  23. current_state2 = False
  24.  
  25. while True:
  26. time.sleep(0.1)
  27. previous_state = current_state
  28. previous_state2 = current_state2
  29. current_state = GPIO.input(sensor)
  30. current_state2 = GPIO.input(sensor2)
  31. if current_state2(TRUE) and current_state(FALSE) != previous_state2(FALSE) and previous_state(FALSE):
  32. new_state = "HIGH"
  33. new_state2 = "HIGH"
  34. if not(current_state and current_state2):
  35. new_state = "LOW"
  36. new_state2 = "LOW"
  37. print("GPIO pin %s is %s" % (sensor, new_state, sensor2, new_state2))
Add Comment
Please, Sign In to add comment