Advertisement
gregwa

FCM#119 - analogue_test1.py

Mar 8th, 2017
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import pyfirmata
  2. PORT = "/dev/ttyACM0"
  3. board = pyfirmata.Arduino(PORT)
  4.  
  5.  
  6. PINS = (0, 1, 2, 3)
  7.  
  8. it = pyfirmata.util.Iterator(board)
  9. it.start()
  10.  
  11.  
  12. for pin in PINS:
  13.     board.analog[pin].enable_reporting()
  14. pin2 = board.get_pin('d:2:o')
  15.  
  16. val = board.analog[0].read()
  17. board.pass_time(1)
  18. while True:
  19.     val = board.analog[0].read()
  20.     print val
  21.     if val >= .50:
  22.         pin2.write(1)
  23.     else:
  24.         pin2.write(0)
  25.     board.pass_time(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement