3837 views|4 replies

73

Posts

0

Resources
The OP
 

What is the difference between pyb.delay and time.sleep? [Copy link]

 

It’s still Xiaobai’s problem.

When learning micropython, I came across pyb.delay and time.sleep, both of which can achieve delay. What is the difference between them, or what impact do they have on the efficiency of the program?

I first came into contact with assembly language, and I have always been unsure about what high-level languages are doing. Recently, I learned micropython and felt that it was very efficient when writing things.

Latest reply

Try to use the time library for delay, which is more versatile. Many of the previous pyb functions have been put into machine, time, etc.   Details Published on 2020-1-18 16:56
 
 

1w

Posts

25

Resources
2
 

There is no difference, they are all delays, the same as the delay in C language.

 
 
 

6

Posts

0

Resources
3
 

There is a difference. If it is a delay in an IC driver, it is strongly recommended to use pyb.delay, which has higher accuracy than time.sleep. I had a driver that was unstable when using time.sleep and would timeout. I changed it to pyb.delay and this problem did not occur.

 
 
 

5

Posts

0

Resources
4
 
pyb.delay(ms) delay in milliseconds, time.sleep(s) delay in seconds, the units are different, I am also learning, for reference only!
 
 
 

1w

Posts

25

Resources
5
 

Try to use the time library for delay, which is more versatile. Many of the previous pyb functions have been put into machine, time, etc.

 
 
 

Guess Your Favourite
Just looking around
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