Demo entry 6718687

Python

   

Submitted by anonymous on Mar 05, 2018 at 16:46
Language: Python. Code size: 722 Bytes.

#!/usr/bin/python

# this library contains functions to control the GPIO pins
import RPi.GPIO as GPIO
import time

# use Broadcom naming convention
GPIO.setmode(GPIO.BCM)
# ignore warnings by default
GPIO.setwarnings(False)

# create a variable for our pin number
ledPin = 21

# configure the ledPin as output and turn on
GPIO.setup(ledPin, GPIO.OUT, initial = GPIO.HIGH)

# wait 1 second
time.sleep(1)
# then turn the led off
GPIO.output(ledPin, GPIO.LOW)
# wait 1 second
time.sleep(1)
# then turn the led on
GPIO.output(ledPin, GPIO.HIGH)
# wait one last second
time.sleep(1)
# then turn the led off
GPIO.output(ledPin, GPIO.LOW)

# reset all the GPIO information and states
GPIO.cleanup()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).