功能 | 注释 | BOARD | BCM | wiringPi | |
LED排灯 | LED-D6 | 第5个LED(绿) | 27 | 0 | 30 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(0, GPIO.OUT) pwm = GPIO.PWM(0, 50) pwm.start(0) pause_time = 0.01 try: while True: for i in xrange(0, 101, 1): pwm.ChangeDutyCycle(i) # off time.sleep(pause_time) time.sleep(1) for i in xrange(100, -1, -1): pwm.ChangeDutyCycle(i) # on time.sleep(pause_time) except KeyboardInterrupt: # stop the white PWM output pwm.stop() # clean up GPIO on CTRL+C exit GPIO.cleanup() |
1 | sudo python breathinglight.py |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import RPi.GPIO as GPIO import time import subprocess GPIO.setmode(GPIO.BCM) GPIO.setup(0, GPIO.OUT) # 默认点亮LED表示正在检测进程 GPIO.output(0, GPIO.LOW) pwm = GPIO.PWM(0, 50) pwm.start(0) pause_time = 0.01 def process_exist(): proc = subprocess.Popen("ps aux | grep wget", stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) stdout = proc.communicate() for line in stdout: if line.count('http') > 0: print(line) return True return False try: while True: if process_exist(): for i in xrange(0, 101, 1): pwm.ChangeDutyCycle(i) # off time.sleep(pause_time) time.sleep(1) for i in xrange(100, -1, -1): pwm.ChangeDutyCycle(i) # on time.sleep(pause_time) else: time.sleep(pause_time * 10) except KeyboardInterrupt: # stop the white PWM output pwm.stop() # clean up GPIO on CTRL+C exit GPIO.cleanup() |
1 | screen sudo python breathinglight.py |
1 | wget http://xxx.xxx.xxx.xxx/test.exe |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |