<jupyter_start><jupyter_text>Mobile breadboard! - Lolin32 Lite Devboard- Led lit NDC front- max7219 8x8 LED Matrix display- DHT22 temperature and humidity sensor- 2x Piezo buzzers- Cat  LED Matrix<jupyter_code>print(1)
import max7219
import time
from machine import Pin, SPI
spi = SPI(-1, 10000000, miso=Pin(19), mosi=Pin(23), sck=Pin(18))
display = max7219.Matrix8x8(spi, Pin(17), 4)
display.brightness(15)
display.fill(0)
display.text('1234',0,0,1)
display.show()
from time import sleep

with open('ledtext.txt', 'r') as f:
    for l in f:
        print(l)
        display.fill(0)
        display.text(l,0,0,1)
        display.show()
        sleep(1)

display.fill(0)
display.show()<jupyter_output><empty_output><jupyter_text>Temperature and humidityDHT22- 1-wire interface (newer have i2c) MicroPython [dht](https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/dht.html) module<jupyter_code>import dht
import machine
d = dht.DHT22(machine.Pin(4))
d.measure()
t = d.temperature()
h = d.humidity()
print("{} degrees and {}% humidity".format(t, h))
display.fill(0)
display.text('{}C'.format(int(t)),0,0,1)
display.show()<jupyter_output><empty_output><jupyter_text>Mobile breadboard<jupyter_code>to_left = Pin(12, Pin.OUT)
to_left.value(0)<jupyter_output><empty_output><jupyter_text>Pulse-width modulation (PWM)- Frequency [Hz]- Duty [%]<jupyter_code>from machine import Pin, PWM
ndc_led = PWM(Pin(27, Pin.OUT), freq=50, duty=0)
to_left = PWM(Pin(12, Pin.OUT), freq=50, duty=0)
to_right = PWM(Pin(14, Pin.OUT), freq=50, duty=0)
to_left.duty()
to_left.duty(0)<jupyter_output><empty_output><jupyter_text>Uasyncio<jupyter_code>import max7219
import uasyncio
from machine import Pin, SPI, PWM

spi = SPI(-1, 10000000, miso=Pin(19), mosi=Pin(23), sck=Pin(18))

display = max7219.Matrix8x8(spi, Pin(17), 4)
display.brightness(15)

buz_ch1 = PWM(Pin(19), freq=440, duty=0)
buz_ch2 = PWM(Pin(32), freq=440, duty=0)
pwm_duty = 400

async def file_to_led():
    while True:
        with open('ledtext.txt', 'r') as f:
            for l in f:
                print(l)
                display.fill(0)
                display.text(l,0,0,1)
                display.show()
                await uasyncio.sleep(0.5)

        display.fill(0)
        display.show()
        await uasyncio.sleep(1)

        
async def temp():
    import dht
    from time import sleep
    
    d = dht.DHT22(Pin(4))
    while True:
        print('measuring..')
        d.measure()
        #await uasyncio.sleep_ms(200)
        t = d.temperature()
        h = d.humidity()
        display.fill(0)
        display.text('{}C'.format(int(t)),0,0,1)
        display.show()
        buz_ch1.duty(0)
        sleep(1)
        await uasyncio.sleep(5)

        
async def play_tone(freq, msec, buz_ch):
    print('{} - freq = {:6.1f} msec = {:6.1f}'.format(buz_ch, freq, msec))
    if freq > 0:
        buz_ch.duty(pwm_duty)
        buz_ch.freq(int(freq))
        await uasyncio.sleep_ms(int(msec * 0.9))
    buz_ch.duty(0)
    await uasyncio.sleep_ms(int(msec * 0.1))


async def play(tune, buz_ch):
    try:
        for freq, msec in tune.notes():
            await play_tone(freq, msec, buz_ch)
    except KeyboardInterrupt:
        await play_tone(0, 0, buz_ch)        
    
    
async def killer():
    print("sleeping {} seconds".format(20))
    await uasyncio.sleep(20)

loop = uasyncio.get_event_loop()
loop.create_task(file_to_led())
loop.create_task(temp())

from rtttl import RTTTL
import songs
loop.create_task(play(RTTTL(songs.find('MissionImp')), buz_ch1))
loop.create_task(play(RTTTL(songs.find('MissionImp')), buz_ch2))

try:
    loop.run_until_complete(killer())
finally:
    buz_ch1.deinit()
    buz_ch2.deinit()
    display.fill(0)
    display.show()<jupyter_output>----

measuring..
PWM(19, freq=440, duty=0) - freq = 1174.8 msec =   78.9
PWM(32, freq=1174, duty=0) - freq = 1174.8 msec =   78.9
sleeping 20 seconds
ALL 

PWM(19, freq=1174, duty=0) - freq = 1244.4 msec =   78.9
PWM(32, freq=1244, duty=0) - freq = 1244.4 msec =   78.9
PWM(19, freq=1244, duty=0) - freq = 1174.8 msec =   78.9
PWM(32, freq=1174, duty=0) - freq = 1174.8 msec =   78.9
PWM(19, freq=1174, duty=0) - freq = 1244.4 msec =   78.9
PWM(32, freq=1244, duty=0) - freq = 1244.4 msec =   78.9
PWM(19, freq=1244, duty=0) - freq = 1174.8 msec =   78.9
PWM(32, freq=1174, duty=0) - freq = 1174.8 msec =   78.9
PWM(19, freq=1174, duty=0) - freq = 1244.4 msec =   78.9
PWM(32, freq=1244, duty=0) - freq = 1244.4 msec =   78.9
PWM(19, freq=1244, duty=0) - freq = 1174.8 msec =   78.9
HAIL

PWM(32, freq=1174, duty=0) - freq = 1174.8 msec =   78.9
PWM(19, freq=1174, duty=0) - freq = 1244.4 msec =   78.9
PWM(32, freq=1244, duty=0) - freq = 1244.4 msec =   78.9
PWM(19, freq=12[...]<jupyter_text>MQTT  HTTP Webserver<jupyter_code>kubernetes lifeline - workwork

192.168.43.147<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15436654366543665, 'fraction_numerical': 0.09020090200902009, 'mean_word_length': 3.2685914260717412, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 25, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '144206', 'license': 'MIT', 'n_tokens_mistral': 2302, 'n_tokens_neox': 2066, 'n_words': 406, 'path': 'final/mobile breadboard.ipynb', 'repo_name': 'SebastianRoll/NDC-MicroPython', 'size': '4878'}