finishtime = 0 rfactor = 1.492 #one RPS factor samples = 300.0 speed = 0.0 directionPin = 18 #GPIO pin speedPin = 23 #GPIO pin state = False #setup GPIO's GPIO.setmode(GPIO.BCM) GPIO.setup(speedPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) #direction wil be switched between in/out (RC circuit) #db connection setup db = connect.getConnect() r = db.cursor() #Direction by RC timing #Test readings - benchmarking #ideal numbers @ 20 deg. C #North = 200 - 230 #NorthWest = 110 - 130 #West = 45 - 60 #SouthWest = 370 - 470 #South = 1830 - 1890 #SouthEast = 2300 - 3600 #East = 6500 - 6800 #NorthEast = 750 - 950
import urllib import re import connect f = urllib.urlopen("http://www.canyouseeme.org/") html_doc = f.read() f.close() m = re.search('(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)',html_doc) print m.group(0) db = connect.getConnect() r = db.cursor() r.execute('''INSERT INTO ip (adr) VALUES (%s)''', m.group(0)) db.commit()