print("Hello, Pi Pico!")
import machine
import time
from machine import Pin, I2C # importamos la funcion pin del modulo machine y la función I2C
from ssd1306 import SSD1306_I2C
#import framebuf
WIDTH = 128 # declaramos el ancho de pantalla OLED
HEIGHT = 64 # declaramos la altura de la pantalla OLED
i2c = I2C(0) # Inicializa I2C usando los valores predeterminados de
# I2C0, SCL= Pin GP9, SDA= Pin GP8, freq = 400000
print("I2C Address : "+hex(i2c.scan()[0]).upper()) # Muestra la dirección del dispositivo en la shell o consola
print("I2C Configuration: "+str(i2c)) # Muestra la configuración I2C en la shell o consola
oled = SSD1306_I2C(WIDTH, HEIGHT, i2c) # Inicializa la pantalla oled
''''
led_13orange = Pin(13, Pin.OUT)
led_14green = Pin(14, Pin.OUT)
led_12red = Pin(12, Pin.OUT)
while True:
led_13orange.value(1)
led_14green.value(0)
led_12red.value(0)
sleep(0.5)
led_13orange.value(0)
led_14green.value(1)
led_12red.value(0)
sleep(2)
led_13orange.value(0)
led_14green.value(0)
led_12red.value(1)
sleep(2)
'''''
button = Pin(6, Pin.IN, Pin.PULL_UP)
button = Pin(6, Pin.IN, Pin.PULL_UP)
button = Pin(6, Pin.IN, Pin.PULL_UP)
led_12red = Pin(12, Pin.OUT)
led_13orange = Pin(13, Pin.OUT)
led_14green = Pin(14, Pin.OUT)
#ldr
from machine import Pin
ldr_Pin = machine.ADC(Pin(28))
button= Pin(6, Pin.IN, Pin.PULL_UP)
rtc = machine.RTC()
rtc.datetime((2023,3,16,11,1,14,0,0)
# Agrega el texto
oled.text("Nairobi:",5,5) # escribimos en la columna 5 fila 5
oled.text("Temp:",5,15) # escribimos en la columna 5 fila 15
oled.text("Hum:",5,35) # escribimos en la columna 5 fila 35
oled.text("Light:",5,45) # escribimos en la columna 5 fila 45
# Finalmente actualiza la pantalla oled para que se muestre la imagen y el texto
oled.show()
while True:
light_value = ldr_Pin.read_u16()
print("Light inrensity:",light_value)
print("\n\n")
print("date",rtc.datetime())
button_state = button.value()
print("Button state",button_state)
led_12red.value(button_state)
led_14green.value(button_state)
led_13orange.value(button_state)