Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created October 11, 2020 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffersGlass/abfdce24cde5bd145c204bb532a84ad0 to your computer and use it in GitHub Desktop.
Save JeffersGlass/abfdce24cde5bd145c204bb532a84ad0 to your computer and use it in GitHub Desktop.
#import the LED object from the gpiozero module
from gpiozero import LED
#import the 'sleep' function from the time module
from time import sleep
#Create a new instance of the LED class, with the parameter '20'
redLed = LED(20)
#Call the 'on' method of the redLed instance, which is given no arguments
redLed.on()
#call the 'sleep' function that we imported from the time module.
#Notice the lack of a a period or dot - this is just a regular old
#Function that we're calling, not the method of an object
sleep(1)
#call the off method of the redLed object, again with no arguments
redLed.off()
sleep(1)
#call the 'blink' method of the redLed object, this time with two arguments
#These are both keyword arguments
redLed.blink(on_time=.2,off_time=.8)
sleep(5)
redLed.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment