2312 views|3 replies

12

Posts

0

Resources
The OP
 

Why doesn't the mp function written by my baby work? [Copy link]

  本帖最后由 15588608145 于 2018-8-5 01:27 编辑

from machine import Pin
from time import sleep_ms

def led_toggle(t):
  LED = Pin(t, Pin.OUT)
    if LED.value() == 1:
      LED(0)   # off
      return(LED.value())
      #sleep_ms(100)
    elif LED.value() == 0:
      LED(1)   # on
      return(LED.value())
      #sleep_ms(100)


Latest reply

Post the complete usage.  Details Published on 2018-9-4 11:29
 
 

12

Posts

0

Resources
2
 
def led_toggle(): LED = Pin(21, Pin.OUT) if LED.value() == 1: LED(0) # off return(LED.value()) #sleep_ms(100) elif LED.value() == 0: LED(1) # on return(LED.value()) #sleep_ms(100) This works... I don't know why
 
 
 

32

Posts

0

Resources
3
 
You can print the type of t to see if the wrong data type is passed in.
 
 
 

1w

Posts

25

Resources
4
 
Post the complete usage.
 
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list