Created
May 2, 2025 06:32
-
-
Save pepinisillo/9ef40109a3d231952c2c93a1a68dd7a4 to your computer and use it in GitHub Desktop.
Conjunto de programas diseñados para la micro:bit, utilizando Python para interactuar con diversos sensores y mostrar resultados en su matriz de LEDs. Cada programa tiene una funcionalidad específica.
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/01 | | |
| # | • Descripción: Programa en Python para micro:bit que muestra una carita | | |
| # | feliz al presionar el botón A, una triste al presionar B, y una sorprendida| | |
| # | al tocar el logo táctil. | | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python •°•═══════ | |
| from microbit import * | |
| # Bucle principal que se ejecuta infinitamente | |
| while True: | |
| # Si se presiona el botón A, muestra una carita feliz | |
| if button_a.is_pressed(): | |
| display.show(Image.HAPPY) | |
| # Si se presiona el botón B, muestra una carita triste | |
| if button_b.is_pressed(): | |
| display.show(Image.SAD) | |
| # Si se toca el logo (parte táctil), muestra una carita sorprendida | |
| if pin_logo.is_touched(): | |
| display.show(Image.SURPRISED) |
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/01 | | |
| # | • Descripción: Programa en Python para micro:bit que muestra la dirección | | |
| # | usando el compás integrado. Muestra grados en pantalla. | | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python •°•═══════ | |
| from microbit import * | |
| import compass | |
| # Calibrar si es necesario | |
| if not compass.is_calibrated(): | |
| compass.calibrate() | |
| while True: | |
| heading = compass.heading() # Obtener grados de dirección (0 a 359) | |
| display.scroll(str(heading)) # Mostrar en la pantalla | |
| sleep(1000) |
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/01 | | |
| # | • Descripción: Programa para micro:bit en Python que muestra en la matriz | | |
| # | de leds del micorbit un corazón a partir de ciertos leds prendidos. | | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python •°•═══════ | |
| # Importa las funciones y clases necesarias para controlar la micro:bit | |
| from microbit import * | |
| # Bucle principal que se repite para siempre | |
| while True: | |
| display.show(Image.HEART) # Muestra un corazón grande en la pantalla LED | |
| sleep(500) # Espera 500 milisegundos (0.5 segundos) | |
| display.show(Image.HEART_SMALL) # Muestra un corazón pequeño | |
| sleep(500) # Espera otros 500 milisegundos |
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/01 | | |
| # | • Descripción: Programa en Python para micro:bit que detecta la inclinación | | |
| # | en los ejes X y Y y muestra una flecha indicando la dirección. | | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python •°•═══════ | |
| from microbit import * | |
| while True: | |
| x = accelerometer.get_x() | |
| y = accelerometer.get_y() | |
| if x < -300: | |
| display.show(Image.ARROW_W) # Inclinación a la izquierda | |
| elif x > 300: | |
| display.show(Image.ARROW_E) # Inclinación a la derecha | |
| elif y < -300: | |
| display.show(Image.ARROW_N) # Inclinación hacia arriba | |
| elif y > 300: | |
| display.show(Image.ARROW_S) # Inclinación hacia abajo | |
| else: | |
| display.clear() # No inclinación significativa |
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/01 | | |
| # | • Descripción: Programa en Python para micro:bit que detecta el sonido del | | |
| # | ambiente; muestra un corazón grande si el sonido es fuerte y uno pequeño | | |
| # | si el sonido es bajo. | | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python •°•═══════ | |
| from microbit import * | |
| # Bucle que se ejecuta continuamente | |
| while True: | |
| # Si se detecta un sonido fuerte (como una palmada) | |
| if microphone.current_event() == SoundEvent.LOUD: | |
| display.show(Image.HEART) # Muestra un corazón grande | |
| sleep(200) # Espera un poco para que se vea el efecto | |
| # Si se detecta silencio o un sonido suave | |
| if microphone.current_event() == SoundEvent.QUIET: | |
| display.show(Image.HEART_SMALL) # Muestra un corazón pequeño |
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/01 | | |
| # | • Descripción: Programa en Python para micro:bit que detecta el gesto de | | |
| # | agitar el dispositivo y muestra en pantalla la cantidad de pasos dados. | | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python •°•═══════ | |
| from microbit import * | |
| # Variable para contar los pasos | |
| steps = 0 | |
| # Bucle principal | |
| while True: | |
| # Si se detecta el gesto de agitar ('shake') | |
| if accelerometer.was_gesture('shake'): | |
| steps += 1 # Aumenta el contador de pasos | |
| display.show(steps) # Muestra el número actual en pantalla | |
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/01 | | |
| # | • Descripción: Programa para micro:bit en Python para comunicarse entre dos | | |
| # | microsbit por medio de radio, enviando mensajes de yes o no. | | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python •°•═══════ | |
| # Importa las librerías necesarias para usar la micro:bit y la radio | |
| from microbit import * | |
| import radio | |
| # Configura el grupo de comunicación por radio al grupo 7 | |
| radio.config(group=7) | |
| # Enciende la funcionalidad de radio | |
| radio.on() | |
| # Bucle principal que se ejecuta continuamente | |
| while True: | |
| # Recibe cualquier mensaje enviado por radio | |
| message = radio.receive() | |
| # Si se recibió un mensaje | |
| if message: | |
| # Si el mensaje es "yes" | |
| if message == 'yes': | |
| display.show(Image.YES) # Muestra el ícono de "sí" en la pantalla | |
| sleep(500) # Espera 0.5 segundos | |
| display.clear() # Limpia la pantalla | |
| # Si el mensaje es "no" | |
| elif message == 'no': | |
| display.show(Image.NO) # Muestra el ícono de "no" | |
| sleep(500) | |
| display.clear() | |
| # Si se presiona el botón A | |
| if button_a.was_pressed(): | |
| radio.send('yes') # Envía "yes" por radio | |
| display.show(Image.YES) # Muestra el ícono de "sí" | |
| sleep(500) | |
| display.clear() | |
| # Si se presiona el botón B | |
| if button_b.was_pressed(): | |
| radio.send('no') # Envía "no" por radio | |
| display.show(Image.NO) # Muestra el ícono de "no" | |
| sleep(500) | |
| display.clear() |
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/01 | | |
| # | • Descripción: Programa en Python para micro:bit que reproduce sonidos y | | |
| # | muestra íconos en la matriz de LEDs según la interacción del usuario: | | |
| # | Botón A muestra felicidad, B tristeza, y el logo sorpresa. | | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python •°•═══════ | |
| from microbit import * | |
| import audio | |
| # Bucle principal que se repite constantemente | |
| while True: | |
| # Si se presiona el botón A | |
| if button_a.is_pressed(): | |
| display.show(Image.HAPPY) # Muestra una cara feliz | |
| audio.play(Sound.HAPPY) # Reproduce un sonido alegre | |
| # Si se presiona el botón B | |
| if button_b.is_pressed(): | |
| display.show(Image.SAD) # Muestra una cara triste | |
| audio.play(Sound.SAD) # Reproduce un sonido triste | |
| # Si se toca el logo (parte superior del micro:bit) | |
| if pin_logo.is_touched(): | |
| display.show(Image.SURPRISED) # Muestra una cara sorprendida | |
| audio.play(Sound.SPRING) # Reproduce un sonido de resorte |
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/01 | | |
| # | • Descripción: Programa en Python para micro:bit que muestra la temperatura | | |
| # | del ambiente al presionar el botón A, usando la matriz de LEDs. | | |
| #  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ | |
| # | |
| # ⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆ | |
| # ═════════•°• Código en lenguaje Python •°•═══════ | |
| from microbit import * | |
| # Bucle que se ejecuta constantemente | |
| while True: | |
| # Si se presiona el botón A | |
| if button_a.was_pressed(): | |
| # Muestra la temperatura actual desplazándose en la pantalla | |
| display.scroll(temperature()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment