from machine import Pin,I2C
import ssd1306
from random import choice
from time import sleep, sleep_ms
i2c = I2C(0, scl=Pin(12), sda=Pin(32))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
led_b = Pin(23, Pin.OUT)
led_j = Pin(19, Pin.OUT)
led_r = Pin(4, Pin.OUT)
led_v = Pin(22, Pin.OUT)
led_bl = Pin(13, Pin.OUT)
button_b = Pin(21, Pin.IN, Pin.PULL_UP)
button_j = Pin(18, Pin.IN, Pin.PULL_UP)
button_r = Pin(5, Pin.IN, Pin.PULL_UP)
button_v = Pin(2, Pin.IN, Pin.PULL_UP)
score = 0
couleurs = ["b","j","r","v"]
buttons = ["led_b","led_j","led_r","led_v"]
sequence_simon = []
compteur=5
test=True
while test:
# ajouter une nouvelle valeur aléatoire dans la séquence simon
while buttons == sequence_simos:
for suite in range (0,compteur):
sequence_simon.append(choice(couleurs))
test=False
# Afficher les LEDS de la séquence simon une par une
print('1')
print ( sequence_simon)
for couleur in sequence_simon:
if couleur == "b":
led_b.on()
sleep(2)
led_b.off()
elif couleur == "j":
led_j.on()
sleep(2)
led_j.off()
elif couleur == "r":
led_r.on()
sleep(2)
led_r.off()
elif couleur == "v":
led_v.on()
sleep(2)
led_v.off ()
sleep (1)
# bon boutton
'''
maxi = 4
for _ in range (0,maxi):
nb_choisi=random.randint(0,3)
if nb_choisi == 0:
led_b.on()
elif nb_choisi == 1:
led_j.value() == 1
elif nb_choisi == 2:
led_r.value() == 1
elif nb_chosi == 3:
led_v.value() == 1
'''