From adc91f24dbbdcaae8ca3f4545accdab38271267b Mon Sep 17 00:00:00 2001 From: GrilloCha Date: Fri, 13 Oct 2023 20:21:38 -0600 Subject: [PATCH 1/4] Se agrego el programa 4 --- Programa4.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Programa4.py diff --git a/Programa4.py b/Programa4.py new file mode 100644 index 0000000..e73cfc2 --- /dev/null +++ b/Programa4.py @@ -0,0 +1,19 @@ +from gpiozero import LED +import time + +ledRojo = LED(17) +ledAmarillo = LED(2) +ledVerde = LED(3) + +while True: + ledVerde.on() + time.sleep(3) + ledVerde.off() + + ledAmarillo.on() + time.sleep(3) + ledAmarillo.off() + + ledRojo.on() + time.sleep(3) + ledRojo.off() \ No newline at end of file From 006d17ff8e89ff5e6dadd52b0abd323bfa089a2f Mon Sep 17 00:00:00 2001 From: GrilloCha Date: Fri, 20 Oct 2023 18:38:05 -0600 Subject: [PATCH 2/4] Se agrego ejercicio 1 del documento ca1 (Registro de boton) --- ca1_ejercicio1.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ca1_ejercicio1.py diff --git a/ca1_ejercicio1.py b/ca1_ejercicio1.py new file mode 100644 index 0000000..1abe750 --- /dev/null +++ b/ca1_ejercicio1.py @@ -0,0 +1,15 @@ +from gpiozero import Button +from time import sleep +from datetime import datetime + +button = Button(2) + +while True: + documentoBoton = open("botonRegistro.txt", "a") + fechaActual = datetime.now().strftime("%Y/%m/%d %H:%M:%S") + if button.is_pressed: + data = f"{fechaActual} --> Boton presionado" + documentoBoton.write(data) + documentoBoton.close() + + \ No newline at end of file From 68560ebeef5f8bb597f1fff3d49bdb9d969d85e4 Mon Sep 17 00:00:00 2001 From: GrilloCha Date: Fri, 20 Oct 2023 18:48:16 -0600 Subject: [PATCH 3/4] =?UTF-8?q?Se=20eficient=C3=B3=20y=20coment=C3=B3=20el?= =?UTF-8?q?=20codigo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ca1_ejercicio1.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ca1_ejercicio1.py b/ca1_ejercicio1.py index 1abe750..d98a217 100644 --- a/ca1_ejercicio1.py +++ b/ca1_ejercicio1.py @@ -1,15 +1,16 @@ from gpiozero import Button -from time import sleep from datetime import datetime +#Establecemos boton en el GPIO2 button = Button(2) -while True: - documentoBoton = open("botonRegistro.txt", "a") - fechaActual = datetime.now().strftime("%Y/%m/%d %H:%M:%S") - if button.is_pressed: - data = f"{fechaActual} --> Boton presionado" - documentoBoton.write(data) - documentoBoton.close() - - \ No newline at end of file +#Creamos y abrimos el documento +with open("botonRegistro.txt", "a") as documentoBoton: + +#Ciclo para comprobar estado del boton + while True: + fechaActual = datetime.now().strftime("%Y/%m/%d %H:%M:%S") + if button.is_pressed: + data = f"{fechaActual} --> Boton presionado\n" + documentoBoton.write(data) + \ No newline at end of file From 0fe4ac4e431d061d28195a63d7d007757213e7d4 Mon Sep 17 00:00:00 2001 From: GrilloCha Date: Fri, 20 Oct 2023 20:23:37 -0600 Subject: [PATCH 4/4] Se agrega ejercicio Ca2 (Sensor de temperatura/humadad con grafico) --- ca2_ejercicio1/ca2_ejercicio1.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 ca2_ejercicio1/ca2_ejercicio1.py diff --git a/ca2_ejercicio1/ca2_ejercicio1.py b/ca2_ejercicio1/ca2_ejercicio1.py new file mode 100644 index 0000000..ea15fb0 --- /dev/null +++ b/ca2_ejercicio1/ca2_ejercicio1.py @@ -0,0 +1,31 @@ +import adafruit_dht +import matplotlib.pyplot as plt +import board + +#Configuramos pin +sensor = adafruit_dht.DHT11(board.D7) + +#Listas para el grafico +temperaturaGrafico = [] +humedadGrafico = [] + +while True: + temperatura_C = sensor.temperature + humedad = sensor.humidity + + # Agregar datos a las listas + temperaturaGrafico.append(temperatura_C) + humedadGrafico.append(humedad) + + #Imprimimos datos + print(f"Temperatura: {temperatura_C} Humedad: {humedad}") + + # Actualizar el gráfico + plt.plot(temperaturaGrafico, color='red', label='Temperatura') + plt.plot(humedadGrafico, color='blue', label='Humedad') + plt.xlabel('Temperatura (C)') + plt.ylabel('Humedad') + plt.title('Temperatura vs Humedad') + plt.grid(True) + plt.draw() + plt.pause(0.1) \ No newline at end of file