file: bascula2db.py
description: Reads interrupts from reed switch and saves timestamp on db
authors: alberto valente <*****@*****.**>, davide grobberio <*****@*****.**>
project: OpenPluvio an OpenSource tipping bucket rain gauge
version: 1.0
organization: Verona FabLab <www.veronafablab.it>
license: CC-BY-SA

'''

from ablib import Pin
from time import sleep
import sqlite3

DBNAME = '/var/www/OpenPluvio/db/openpluvio'

def basculata():
    connection = sqlite3.connect(DBNAME)
    cursor = connection.cursor()
    cursor.execute('insert into basculate default values')
    connection.commit()
    connection.close()

PB=Pin('PC0','INPUT')
PB.set_edge("falling",basculata)

#Never ending loop
while True:
    sleep
   
'''
file: reedTest.py
description: Reads interrupts from reed switch for debug purposes
authors: alberto valente <*****@*****.**>, davide grobberio <*****@*****.**>
project: OpenPluvio an OpenSource tipping bucket rain gauge
version: 1.0
organization: Verona FabLab <www.veronafablab.it>
license: CC-BY-SA

'''
from ablib import Pin
from time import sleep

def pressed():
    print "Pressed"

PB=Pin('PC0','INPUT')
PB.set_edge("falling",pressed)

#Never ending loop
i=0
while True:
    print i
    i=i+1
    sleep(0.5)