Advertisement
Guest User

just another day in yyy

a guest
Jan 20th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # Each 5 min walk must be a minimum of 300 steps, at least 1 hour apart.
  4. # 6 walks, 30 mins a peice at 1 step at a little more than half a second a step
  5. # should complete all 3 goals.
  6. import RPi.GPIO as GPIO
  7. import time
  8.  
  9. GPIO.setmode(GPIO.BOARD)
  10.  
  11. GPIO.setup(12, GPIO.OUT)
  12.  
  13. p = GPIO.PWM(12, 50)
  14.  
  15. p.start(7.5)
  16.  
  17. try:
  18.     for i in xrange(0, 6): # 6 walks
  19.         for j in xrange(0, 3000): # 3000 steps
  20.             p.ChangeDutyCycle(7.5)  # turn towards 90 degree
  21.             time.sleep(.1)  # sleep 1 second
  22.             p.ChangeDutyCycle(2.5)  # turn towards 0 degree
  23.             time.sleep(.1)  # sleep 1 second
  24.             p.ChangeDutyCycle(12.5)  # turn towards 180 degree
  25.             time.sleep(.5)  # sleep 1 second
  26.         time.sleep(60*60) # wait an hour
  27. except KeyboardInterrupt:
  28.     p.stop()
  29.     GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement