Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- # Each 5 min walk must be a minimum of 300 steps, at least 1 hour apart.
- # 6 walks, 30 mins a peice at 1 step at a little more than half a second a step
- # should complete all 3 goals.
- import RPi.GPIO as GPIO
- import time
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(12, GPIO.OUT)
- p = GPIO.PWM(12, 50)
- p.start(7.5)
- try:
- for i in xrange(0, 6): # 6 walks
- for j in xrange(0, 3000): # 3000 steps
- p.ChangeDutyCycle(7.5) # turn towards 90 degree
- time.sleep(.1) # sleep 1 second
- p.ChangeDutyCycle(2.5) # turn towards 0 degree
- time.sleep(.1) # sleep 1 second
- p.ChangeDutyCycle(12.5) # turn towards 180 degree
- time.sleep(.5) # sleep 1 second
- time.sleep(60*60) # wait an hour
- except KeyboardInterrupt:
- p.stop()
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement