from machine import Pin, PWM
import time
pin_led = PWM(Pin(16, mode=Pin.OUT))
pin_bpblue = Pin(20, mode=Pin.IN)
pin_bpred = Pin(21, mode=Pin.IN)
led=0
gyro = 0

while True:
    etat_BPblue = pin_bpblue.value()
    etat_BPred = pin_bpred.value()
    if (etat_BPred == False) and (etat_BPblue == False):
        print('Nous avons besoin de votre aide')
    elif (etat_BPblue == False):
        print('Bonjour habitants de la planète Algoréa')
        while gyro <= 10:
            pin_led.value(True)
            time.sleep(0.1)
            pin_led.value(False)
            time.sleep(0.1)
            gyro = gyro +1
    elif (etat_BPred == False):
        print('Nous venons de la planète Terre')
        if led == 0:
            pin_led.value(True)
            led = 1
        elif led == 1:
            pin_led.value(False)
            led = 0 
            
    else:
        print('Released')
        
    time.sleep(0.5)
    gyro = 0
    '''
    pin_led.value(True)
    time.sleep(1)
    pin_led.value(False)
    time.sleep(1)
    '''