1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
def ADC (event=None):
global valueADC, values
for i in range(10):
vals = adc.read_adc(1, gain=GAIN)
values.append(vals)
print('| {0:>6} |'.format(vals))
valueADCx= (sum (values)/len(values))
valueADC.set(valueADCx)
for i in range(10):
values[i]= values[i-1]
values[-1]=vals
'''valueADC= moyenne(values)'''
print (valueADCx)
label9.after(100,ADC)
root=Tk
bouton3=Button(root,text="Donnée", command= ADC, padx=10, pady=10, width=10)
bouton3.config(font=('arial', 12, 'bold'))
bouton3.grid(row=2, column=1)
valueADC=StringVar()
label9=Label(root, textvariable=valueADC, width=12, height=2)
label9.config(font=('arial', 15, 'bold'))
label9.grid(row=2, column=2)
root=mainloop() |
Partager