Created
May 6, 2025 22:38
-
-
Save pepinisillo/453ac871bd3e7ba8ed71c0a4ad811b83 to your computer and use it in GitHub Desktop.
Control de tráfico escolar con conteo de pasos y radio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ♡ ∩_∩ | |
| # („• ֊ •„)♡ | |
| # | ̄U U ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄| | |
| # | • Lenguajes de Interfaz en TECNM Campus ITT | | |
| # | • Autor: Alejandro Suarez Sandoval | | |
| # | • Fecha: 2025/05/06 | | |
| # | • Descripción: Programa en Python para micro:bit que cuenta los pasos | | |
| # | de un estudiante o varios estudiantes y estos son mostrados a un micro:bit | | |
| # | central que puede ser de un maestro para control de trafico de alumnos. | | |
| # | • Evidencia: https://imgur.com/a/811eDlj | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python micro:bit alumno•°•═══════ | |
| from microbit import * | |
| import radio | |
| radio.on() | |
| # El microbit del maestro y alumno deben estar en el mismo grupo | |
| radio.config(group=23) | |
| steps = 0 | |
| was_moving = False | |
| while True: | |
| # Detecta movimiento en el eje Y (paso simple) | |
| moving = abs(accelerometer.get_y()) > 150 | |
| if moving and not was_moving: | |
| steps += 1 | |
| display.show(str(steps % 10)) # muestra últimos pasos | |
| # cada 10 pasos, envía señal | |
| if steps % 10 == 0: | |
| radio.send("steps:10") | |
| was_moving = moving | |
| sleep(200) | |
| # ═════════•°• Código en lenguaje Python micro:bit maestro•°•═══════ | |
| from microbit import * | |
| import radio | |
| radio.on() | |
| radio.config(group=23) | |
| total = 0 | |
| while True: | |
| # Muestra el mensaje de los pasos del alumno | |
| msg = radio.receive() | |
| if msg and msg.startswith("steps:"): | |
| n = int(msg.split(":")[1]) | |
| total += n | |
| display.scroll("T:" + str(total)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment