外接輸出裝置(以LED燈為例)
-
亮燈
#!/usr/bin/python #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ #|R|a|s|p|b|e|r|r|y|P|i|.|c|o|m|.|t|w| #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ # Copyright (c) 2016, raspberrypi.com.tw # All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # # led_on.py # Turn on a led # # Author : sosorry # Date : 06/22/2014 import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) LED_PIN = 12 GPIO.setup(LED_PIN, GPIO.OUT) print("LED is on") GPIO.output(LED_PIN, GPIO.HIGH) time.sleep(3) GPIO.cleanup()
本單元影片由財團法人善科教育基金會贊助,由南港高中第一屆數位科學實驗班董仁鈞同學製作。
-