
from Arduino import Arduino
import time

ard = Arduino('COM4',[4,4,4,4,4])
time.sleep(1)
RAPPORT = 0
TENSION = 1
KP = 2
KI = 3
KD = 4

Kp = 0.01
Ti = 1e-3
Ki = Kp/Ti # ou bien Ki=0 pour enlever l'intégrateur
Td = 0
Kd = Kp*Td


ard.write_float(KP,Kp)
ard.write_float(KI,Ki)
ard.write_float(KD,Kd)

while True:
    r = input('?')
    if r=='n': break
    elif r=="v":
        Vs = ard.read_float(TENSION)
        print("Vs = %f"%Vs)
    else:
        tension = float(r)
        ard.write_float(TENSION,tension)

ard.close()

       
                                 