Advertisement
tomateblue

Blink

Jun 3rd, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. from pyfirmata import Arduino, util  # importa classe PyFirmata e time
  2. import time                            
  3.  
  4. board = Arduino('/dev/ttyACM0')  # em board criamos uma instancia usando a porta onde nosso arduino esta
  5.  
  6. def delay(second):  # função delay igual temos no arduino
  7.   time.sleep(second)  
  8.  
  9. def blink(second):  # função blink usada para piscar led
  10.  # board --> porta digital --> pino 13 write -> 1 Ligado
  11.   board.digital[13].write(1)  
  12.   delay(second)
  13.  # board --> porta digital --> pino 13 write -> 0 desligado
  14.   board.digital[13].write(0)
  15.   delay(second)
  16.  
  17. x = 0
  18. while x < 10:
  19.  x = x + 1
  20.  print x
  21.  blink(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement