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
Why my simple LED example is not toggling
-
- Posts: 118
- Joined: Wed Dec 27, 2017 8:52 am
Why my simple LED example is not toggling
Here is my simple example to blink LED, and i guess it was working properly previously but its not working now.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Why my simple LED example is not toggling
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.
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
while (True):
led1.low() #Turning LED ON
pyb.delay(5000)
led1.high() #Turning LED OFF
pyb.delay(5000)
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)
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 118
- Joined: Wed Dec 27, 2017 8:52 am
Re: Why my simple LED example is not toggling
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.
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())