Ticker

6/recent/ticker-posts

Control the on-board LED using Python

Last post show how to control Raspberry Pi on-board LED OK or ACT in command line. This post show the Python code to control it.

Control the on-board LED using Python
Control the on-board LED using Python
Log-in as root, and enter the Python code. It will turn OFF and ON the on-board LED OK or ACT 4 times.

pythonGPIO.py
import RPi.GPIO as GPIO
import time

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(16, GPIO.OUT)

for num in range(1, 5):
print num
GPIO.output(16, True) ##Turn OFF LED
print "LED OFF"
time.sleep(2)
GPIO.output(16, False) ##Turn ON LED
print "LED ON"
time.sleep(1)




Updated:
- Python/RPi.GPIO Control Raspberry Pi 2 B on-board ACT LED
Python control Raspberry Pi 2 PWR/ACT LED, using RPi.GPIO or system's shell


إرسال تعليق

0 تعليقات