def dashboard(): #update all periodic ana log and digital inputs adc1=TINK.getADC(0,1) #\ adc2=TINK.getADC(0,2) # \___Read all analog inputs adc3=TINK.getADC(0,3) # / adc4=TINK.getADC(0,4) #/ adcVal1.value=str("{:2.3f}".format(TINK.getADC(0,1))) #\ adcVal2.value=str("{:2.3f}".format(TINK.getADC(0,2))) # \_Format analog values update data on screen adcVal3.value=str("{:2.3f}".format(TINK.getADC(0,3))) # / adcVal4.value=str("{:2.3f}".format(TINK.getADC(0,4))) #/ dinVal1.value=str(TINK.getDIN(0,1)) #\ dinVal2.value=str(TINK.getDIN(0,2)) # \___Read all digital inputs and update data on screen dinVal3.value=str(TINK.getDIN(0,3)) # / dinVal4.value=str(TINK.getDIN(0,4)) #/
import piplates.TINKERplate as TINK import time TINK.setDEFAULTS(0) #initialize Digital I/O ports TINK.setMODE(0, 2, 'din') #set port 2 as an input for the motion sensor TINK.setMODE(0, 3, 'dout') #set port 3 as an output for the siren while (True): motion = TINK.getDIN(0, 2) #read motion sensor status if (motion == 1): #if motion detected TINK.relayON(0, 1) #turn on lamp TINK.setDOUT(0, 3) #turn on siren else: #if no motion TINK.relayOFF(0, 1) #turn off lamp TINK.clrDOUT(0, 3) #turn off siren time.sleep(0.1) #wait 100msec and repeat