2018011379-罗时弘

来自iCenter Wiki
跳转至: 导航搜索

2018级 计算机系 本科

2019/04/23 智能硬件-树莓派基础操作

了解树梅派基础使用方式 (基础操作&连接) 编写简单硬件控制程序(by Python) (LED灯控制)

  1. button.py

import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(24,GPIO.IN) GPIO.setup(25,GPIO.OUT)

def twinkle(): GPIO.output(25,GPIO.HIGH) time.sleep(0.1) GPIO.output(25,GPIO.LOW) time.sleep(0.1)


While True: inputValue = GPIO.input(24) if (inputValue == True): twinkle() else: GPIO.output(25,GPIO.LOW) time.sleep(.01)


程序运行截图