import machine
import utime
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
# Configuration des broches
B_P1= 14 # Broche du premier bouton
B_P2 = 15 # Broche du deuxième bouton
RED_PIN = 20 # Broche de la LED rouge
GREEN_PIN = 19 # Broche de la LED verte
BLUE_PIN = 18 # Broche de la LED bleue
# Initialisation des broches
Bouton_1 = Pin(B_P1, Pin.IN, Pin.PULL_UP)
Bouton_2 = Pin(B_P2, Pin.IN, Pin.PULL_UP)
led_red = Pin(RED_PIN, Pin.OUT)
led_green = Pin(GREEN_PIN, Pin.OUT)
led_blue = Pin(BLUE_PIN, Pin.OUT)
# Configuration de l'écran OLED
i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
# Boucle principale
while True:
if not Bouton_1.value():
# Bouton 1 pressé
led_red.on() # LED rouge ON
led_green.off() # LED verte OFF
led_blue.off() # LED bleue OFF
oled.fill(0) # RESET OLED
oled.text("RFID inconnu", 0, 0)
oled.show()
utime.sleep(2)
elif not Bouton_2.value():
# Bouton 2 pressé
led_red.off() # LED rouge OFF
led_green.on() # LED verte ON
led_blue.off() # LED bleue OFF
oled.fill(0) # RESET OLED
oled.text("RFID autorise", 0, 0)
oled.show()
utime.sleep(2)
else:
# Aucun bouton pressé
led_red.off() # LED rouge OFF
led_green.off() # LED verte OFF
led_blue.on() # LED bleue ON
oled.fill(0) # OLED RESET
oled.text("Scanner votre", 0, 0)
oled.text("badge RFID", 0, 16)
oled.show()
utime.sleep(0.1) #Evite les bugs
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
rgb1:R
rgb1:COM
rgb1:G
rgb1:B
oled1:GND
oled1:VCC
oled1:SCL
oled1:SDA