User Tools

Site Tools


gpio_led_control

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gpio_led_control [2016/08/09 18:49] walkeradmingpio_led_control [2023/03/09 22:35] (current) – external edit 127.0.0.1
Line 8: Line 8:
 \\  \\ 
 \\  \\ 
-**Please be aware, the GPIO pins are 3.3v Logic, and are restricted to 16mA**+**Please be aware, the GPIO pins are 3.3v Logic, and are restricted to 16mA - exceeding 16 mA will damage your Pi**
 \\  \\ 
 \\  \\ 
Line 34: Line 34:
     #import modules     #import modules
     import RPi.GPIO as GPIO    # This imports the GPIO libarary that allows the use of the GPIO pins,     import RPi.GPIO as GPIO    # This imports the GPIO libarary that allows the use of the GPIO pins,
-    import time               # This imports the time libarary (for delays among other things)+    import time                # This imports the time libarary (for delays among other things)
                                # These libraries are built in to Raspbian.                                # These libraries are built in to Raspbian.
          
          
-    GPIO.setmode(GPIO.BOARD)   # This sets the GPIO pin numbering. Our LED is connected to Pin 12,+    GPIO.setmode (GPIO.BOARD)  # This sets the GPIO pin numbering. Our LED is connected to Pin 12,
                                # so we can reference it by using BOARD as pin 12. However there is                                # so we can reference it by using BOARD as pin 12. However there is
                                # another option (BCM) where we can reference a pin by it's name, pin                                # another option (BCM) where we can reference a pin by it's name, pin
Line 46: Line 46:
                                # read in a voltage (but only in terms of a 0 or a 1))                                # read in a voltage (but only in terms of a 0 or a 1))
          
-    GPIO.output(12, GPIO.LOW # sets the GPIO Pin 12 to low (so 0v)+    GPIO.output(12, 0        # sets the GPIO Pin 12 to low (so 0v)
          
-    time.sleep(3)+    time.sleep(1)              # waits one second (settling time)
          
-    GPIO.output(12, GPIO.HIGH) # sets the GPIO Pin 12 to hight (so 3.3v)+    GPIO.output(12, 1        # sets the GPIO Pin 12 to high (so 3.3v) LED will turn on
          
 +    time.sleep(3)              # waits 3 seconds, so LED will be on for 3 seconds
          
-    GPIO.cleanup()             # Resets all the GPIO pins to their default state+    GPIO.cleanup()             # Resets all the GPIO pins to their default state (LED will go off)
 \\  \\ 
 \\  \\ 
Line 61: Line 62:
 \\  \\ 
 The LED should come on for 3 seconds, then go off. The program will then end. The LED should come on for 3 seconds, then go off. The program will then end.
 +\\ 
 +\\ 
 +You can see it in operation Here: {{:led_video.mp4|950x574|autoplay,loop}}
 +\\ 
 +**Remember:**
 +
 +Pins are 3.3v
 +\\ 
 +16mA MAX
 +\\ 
 +\\ 
 +This guide is comprised of information from a youtube video by **Gaven MacDonald**. Thanks Gaven.
 \\  \\ 
 \\  \\ 
  
gpio_led_control.1470764967.txt.gz · Last modified: 2023/03/09 22:35 (external edit)