Skip to content

Instantly share code, notes, and snippets.

@kimondo
Created May 1, 2015 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimondo/ba648912c64179e7b8b8 to your computer and use it in GitHub Desktop.
Save kimondo/ba648912c64179e7b8b8 to your computer and use it in GitHub Desktop.
Raspberry Pi Swingometer
import RPi.GPIO as GPIO
import time
from BeautifulSoup import BeautifulSoup
import urllib2
#change this bit
url="http://www.kimondo.co.uk/swingometer-control/"
page=urllib2.urlopen(url)
soup = BeautifulSoup(page.read())
value = soup.find('span',{'style':'color: #99cc00;'})
value = value.next
value = float(value)
print value
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
pwm = GPIO.PWM(18, 100)
pwm.start(5)
t_end = time.time() + 1
while time.time() < t_end:
print value
angle = value/100.0 * 180
print angle
duty = float(angle) / 10.0 + 2.5
pwm.ChangeDutyCycle(duty)
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment