Advertisement
LovelessIsma

puenteh2

Nov 5th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. import RPi.GPIO as gpio
  2. import time
  3.  
  4. def init():
  5.  gpio.setmode(gpio.BCM)
  6.  gpio.setup(17, gpio.OUT)
  7.  gpio.setup(22, gpio.OUT)
  8.  gpio.setup(23, gpio.OUT)
  9.  gpio.setup(24, gpio.OUT)
  10.  
  11. def forward(sec):
  12.  init()
  13.  gpio.output(17, True)
  14.  gpio.output(22, False)
  15.  gpio.output(23, True)
  16.  gpio.output(24, False)
  17.  time.sleep(sec)
  18.  gpio.cleanup()
  19.  
  20. def reverse(sec):
  21.  init()
  22.  gpio.output(17, False)
  23.  gpio.output(22, True)
  24.  gpio.output(23, False)
  25.  gpio.output(24, True)
  26.  time.sleep(sec)
  27.  gpio.cleanup()
  28.  
  29. print "forward"
  30. forward(4)
  31. print "reverse"
  32. reverse(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement