Page 1 of 1

Why my simple LED example is not toggling

Posted: Mon Mar 26, 2018 5:55 am
by nikhiledutech
Here is my simple example to blink LED, and i guess it was working properly previously but its not working now.
import pyb
from pyb import Pin, delay


#Initalising LED Pins
led1 = pyb.Pin('PE8', Pin.OUT, Pin.PULL_DOWN)

#Blinking lEd
while (True):
led1.low() #Turning LED ON
pyb.delay(5000)
led1.high() #Turning LED OFF

Re: Why my simple LED example is not toggling

Posted: Mon Mar 26, 2018 6:24 am
by pythoncoder
Your code needs another delay. As written it turns the LED off but turns it on again so quickly that you'll never see the blink.

Code: Select all

while (True):
    led1.low() #Turning LED ON
    pyb.delay(5000)
    led1.high() #Turning LED OFF
    pyb.delay(5000)
As a general comment it's best to be consistent: use one or the other of import pyb or from pyb import Pin, delay:

Code: Select all

import pyb
#Initalising LED Pins
led1 = pyb.Pin('PE8', pyb.Pin.OUT, pyb.Pin.PULL_DOWN)

#Blinking LED
while (True):
    led1.low()        #Turning LED ON
    pyb.delay(5000)
    led1.high()       #Turning LED OFF
    pyb.delay(5000)

Re: Why my simple LED example is not toggling

Posted: Mon Mar 26, 2018 7:02 am
by nikhiledutech
Also there is some issues with LCD example. I have created this example before 2-3 months. But its not working now. Did any library got updated.

The below code dont give me error, but it dont give me output either.
import uasyncio as asyncio
import utime as time
from alcd import LCD, PINLIST

lcd = LCD(PINLIST, cols = 16)

async def lcd_task():
for secs in range(20, -1, -1):
lcd[0] = 'Edutech Learning'
lcd[1] = "Solution"
await asyncio.sleep(1)


loop = asyncio.get_event_loop()
loop.run_until_complete(lcd_task())