The Pin Remapping Library `dualmcu v0.0.3` for the DualMCU ONE board ensures compatibility with Arduino shields when using MicroPython.
Project description
DualMCU v0.0.3
The Pin Remapping Library dualmcu v0.0.3
for the DualMCU ONE board ensures compatibility with Arduino shields when using MicroPython.
Installation
- Open Thonny.
- Go to Tools -> Manage Packages.
- Enter
onelib
in the search bar and click Install.
Example of use
- Connect Multi-purpose Shield to DualMCU ONE
- Open Thonny and connect to the DualMCU ONE board.
- Run the following code:
from machine import Pin, PWM
from dualmcu import D5
import time
# Configuración del pin D5 para PWM
buzzer = PWM(Pin(D5))
def play_tone(frequency, duration):
buzzer.freq(frequency)
buzzer.duty_u16(32768) # Configura el duty cycle al 50%
time.sleep(duration)
buzzer.duty_u16(0) # Apaga el buzzer
try:
while True:
# Toca una secuencia de tonos
play_tone(262, 0.5) # Do
time.sleep(0.1)
play_tone(294, 0.5) # Re
time.sleep(0.1)
play_tone(330, 0.5) # Mi
time.sleep(0.1)
play_tone(349, 0.5) # Fa
time.sleep(0.1)
play_tone(392, 0.5) # Sol
time.sleep(0.1)
play_tone(440, 0.5) # La
time.sleep(0.1)
play_tone(494, 0.5) # Si
time.sleep(0.1)
play_tone(523, 0.5) # Do
time.sleep(0.1)
except KeyboardInterrupt:
# Detener el buzzer cuando se interrumpe el programa
buzzer.deinit()
- You should hear a sequence of tones.
Ejemplo de uso con la clase Shield
from pins_lib import D5, D9, D10, D11, Shield
# Crear una instancia de Shield
my_shield = Shield(pin_red=D9, pin_green=D10, pin_blue=D11, pin_buzzer=D5)
try:
while True:
# Toca una secuencia de tonos y cambia los colores del LED
my_shield.set_led('red')
my_shield.play_tone(262, 0.5) # Do
time.sleep(0.1)
my_shield.set_led('green')
my_shield.play_tone(294, 0.5) # Re
time.sleep(0.1)
my_shield.set_led('blue')
my_shield.play_tone(330, 0.5) # Mi
time.sleep(0.1)
my_shield.set_led('yellow')
my_shield.play_tone(349, 0.5) # Fa
time.sleep(0.1)
my_shield.set_led('cyan')
my_shield.play_tone(392, 0.5) # Sol
time.sleep(0.1)
my_shield.set_led('magenta')
my_shield.play_tone(440, 0.5) # La
time.sleep(0.1)
my_shield.set_led('white')
my_shield.play_tone(494, 0.5) # Si
time.sleep(0.1)
my_shield.set_led('off')
my_shield.play_tone(523, 0.5) # Do
time.sleep(0.1)
except KeyboardInterrupt:
# Detener el shield cuando se interrumpe el programa
my_shield.deinit()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file dualmcu-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: dualmcu-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d948f953d66dca0fcc971e2e623047fc6bb9b3ab5b018ed935f8961296b37ed |
|
MD5 | 7c1ff33144ca477225d7e4e97b0a0e8c |
|
BLAKE2b-256 | d7d7c520bbccb2fae4334c55cb3c2779089b00299372af7191e4013573fba11e |