1 year ago

#337762

test-img

user06931912

No blink in dummy morse code with rasp pi

I have the following code. Experimenting with it, but the led turns on and stays on until the end. Not sure why.

import machine
import utime

letterMapping = {"h" : "ssss",
                 "e" : "s",
                 "l" : "slss",
                 "o" : "lll",
                 "w" : "sll",
                 "r" : "sls",
                 "d" : "lss",
                 "s" : "sss"}

message = "sos"

def printLetter(snd):
    for i in snd:
        #print(i)
        if i == "s":
            led.value(1)
            utime.sleep(.5)
            led.value(0)
        else:
            led.value(1)
            utime.sleep(1)
            led.value(0)

led = machine.Pin(25, machine.Pin.OUT)

for i in message:
    if (i == " "):
        print("break")
    else:
        #print("\n\nfor letter \n\n" + i)
        printLetter(letterMapping[i])

the led stays on from the beggining to the end. it doesn't blink. any suggestions?

python

raspberry-pi-pico

0 Answers

Your Answer

Accepted video resources