当前位置:网站首页>Raspberry pie 4B parsing PWM
Raspberry pie 4B parsing PWM
2022-07-25 08:02:00 【K.L.Zous】

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
pin=18
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin, GPIO.IN)
while True:
# Wait for the low level to end , Then record the time
while GPIO.input(pin) == 0: # Capture the rising edge of the signal output
pass
time1 = time.time()
# Wait for the high level to end , Then record the time
while GPIO.input(pin) == 1: # Capture the falling edge of signal end output
pass
time2 = time.time()
# Wait for the low level to end , Then record the time
while GPIO.input(pin) == 0: # Capture the rising edge of the signal output
pass
time3 = time.time()
#print(time1)
#print(time2)
#print(time3)
period = time3 - time1
high_time = time2 - time1
low_time = time3 - time2
duty_cycle = (int)(high_time * 100 / period*100)
print(duty_cycle)
time.sleep(0.1)
#print("-------------------------")
边栏推荐
- Teach you to understand the computer optometry sheet
- [unity introduction program] basic concepts -2d rigid body 2D
- eval与assert一句话木马分析
- Redis core principles
- Sqlserver has opened the CDC table. Why can we only pull the full amount of data and can't recognize the incremental data
- How to create a simple electron desktop program
- Advanced C language (XIII) - Example Analysis of dynamic memory management
- Interview questions: common faults and occurrence scenarios of redis
- mysql 如何获取两个集合的交集/差集/并集
- [unity entry program] basic concept trigger
猜你喜欢

滴滴 - dispatching

Network file storage system (II) practical operation of Minio distributed file system

Didi - dispatching

Check the computer restart times and reasons

Nano data, football data, football match scores, sports data API, Qatar world cup

Leetcode (Sword finger offer) - 04. search in two-dimensional array
Mysql-5.7 installation
Technical Analysis | Doris connector combined with Flink CDC to achieve accurate access to MySQL database and table exactly once

交叉熵计算公式

Advanced C language (XII) - dynamic memory management
随机推荐
Redis core principles
[audio and video] picture YUV data format
Calculation formula of cross entropy
如何仅用递归函数和栈操作逆序一个栈
Acnet: asymmetric convolution for image hypersegmentation (with implementation code)
mysql 如何获取两个集合的交集/差集/并集
Niuke dynamic planning training
Introduction and principle explanation of 30 common sensor modules in IOT embedded devices
How to do a good job in safety development?
Recommend 7 open source projects of yyds this week
机器学习理论及案例分析(part1)--机器学习基础
Big guy Qiu zhaomianjing
用一个栈实现另一个栈的排序
While (~scanf ("%d", & n)) is equivalent to while (scanf ("%d", & n)! =eof)
Polling, interrupt, DMA and channel
One of C language multithreading programming
What products and funds should novices invest in first?
Summer Challenge harmonyos - slider slider for custom components
Nano data, football data, football match scores, sports data API, Qatar world cup
Surpassing transformer, Tsinghua, byte significantly refresh parallel text generation SOTA performance | ICML 2022