from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
from random import randint
import utime
i2c=I2C(0,sda=Pin(0), scl=Pin(1), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
red = Pin(13, Pin.OUT)
green = Pin(14, Pin.OUT)
blue = Pin(15, Pin.OUT)
while True:
num = randint(1, 20)
oled = SSD1306_I2C(128, 64, i2c)
oled.text("Numero: " + str(num), 0, 10)
if num % 2 == 0:
red.value(1)
green.value(0)
blue.value(0)
print("Numero:", num, "- PAR (ROJO)")
oled.text("PAR - ROJO", 0, 35)
else:
red.value(0)
green.value(1)
blue.value(0)
print("Numero:", num, "- IMPAR (VERDE)")
oled.text("IMPAR - VERDE", 0, 35)
oled.show()
utime.sleep(2)Loading
ssd1306
ssd1306