The Pin Remapping Library dualmcu v0.0.4 for the DualMCU ONE board ensures compatibility with Arduino shields when using MicroPython. Version 0.0.4 also adds compatibility with the OLED SSD1306 display.
Project description
DualMCU v0.0.4
The Pin Remapping Library dualmcu v0.0.4 for the DualMCU ONE board ensures compatibility with Arduino shields when using MicroPython. This version includes a driver compatible with SSD1306 OLED displays.
Installation
- Open Thonny.
- Go to Tools -> Manage Packages.
- Enter
dualmcu
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()
Code example I2C
Code example
'''
Unit Electronics 2024
(o_
(o_ //\
(/)_ V_/_
tested code mark
'''
import machine
from dualmcu import SSD1306_I2C
i2c = machine.I2C(0,sda=machine.Pin(21), scl=machine.Pin(22))
oled = SSD1306_I2C(128, 32, i2c)
oled.fill(1)
oled.show()
oled.fill(0)
oled.show()
oled.text('UNIT', 50, 10)
oled.text('ELECTRONICS', 25, 20)
oled.show()
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.4-py3-none-any.whl
.
File metadata
- Download URL: dualmcu-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.9 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 | 9b5571f898e0d81ec44a874f9203225856ca4f1f48d1db2ed8a6fe75cf5be4e9 |
|
MD5 | 7b3b17738d12c3e2aee92c000110d023 |
|
BLAKE2b-256 | 55953390b6fe99443440086d83fdc50b0190d96ae7186bab2a656fad92944962 |