Exemplo n.º 1
0
import piplates.TINKERplate as TINK  #import TINKERplate module
import math  #import math module - needed for sine and pi
import time  #import the time module - needed for sleep

Mag=10
N=360
mColor=(255,255,0) #this tuple represents the color yellow
TINK.openMETER(4)  #create a panel meter with the default of a single line
TINK.setCOLOR(mColor)   #set meter color
TINK.setTITLE('Trigonometery Functions')    #Set meter title
while(True):  #Loop forever
    for i in range(N):   #do this 360 times
        TINK.setMETER(i,'degrees','Angle:',1)   #write angle to line 1
        val=math.sin(2*math.pi*i/360)           #calculate sine of angle
        TINK.setMETER(val,'','Sine:',2)         #write sine value to line 2
        val=math.cos(2*math.pi*i/360)           #calculate cosine of angle
        TINK.setMETER(val,'','Cosine:',3)       #write cosine value to line 3
        val=math.tan(2*math.pi*i/360)           #calculate tangent of angle
        TINK.setMETER(val,'','Tangent:',4)      #write tangent value to line 4        
        time.sleep(0.1)
    
    
import piplates.TINKERplate as TINK
import time

TINK.openMETER(1)  #Create a display meter on the screen

while (True):
    pot = TINK.getADC(0, 4)
    TINK.setMETER(pot, 'Level', 'Water:')
    time.sleep(.5)
Exemplo n.º 3
0
import piplates.TINKERplate as TINK
import time

#create battery state thresholds
VL = 1.2
VH = 1.4

TINK.openMETER(1)  #Create a panel meter on the screen

#Change window title:
TINK.setTITLE("TINKERplate Battery Tester")
#TINK.setCOLOR((255,0,0))   #start with red text

while (True):
    bat = TINK.getADC(0, 1)  #read analog chanel 1
    if (bat >= VH):
        TINK.setCOLOR((0, 255, 0))  #show green text
        TINK.setMETER(bat, 'Volts', 'GOOD', 1)  #indicate a GOOD battery
    if ((bat >= VL) and (bat < VH)):
        TINK.setCOLOR((255, 255, 0))  #show yellow text
        TINK.setMETER(bat, 'Volts', 'OK', 1)  #indicate an OK battery
    if (bat < VL):
        TINK.setCOLOR((255, 0, 0))  #show red text
        TINK.setMETER(bat, 'Volts', 'BAD', 1)  #indicate a BAD battery
    time.sleep(.5)  #delay and repeat