from machine import Timer, Pin

pin_b  = Pin(2, mode=Pin.OUT)
timer_0 = Timer(0) # Entre 0-3 pour la carte ESP32

def travail(timer_0):
    pin_b.value(not pin_b.value())

if __name__ == "__main__":
    timer_0.init(mode=Timer.PERIODIC, period=500, callback=travail)