Skip to content

Latest commit

 

History

History
75 lines (52 loc) · 1.55 KB

blinking_LED.md

File metadata and controls

75 lines (52 loc) · 1.55 KB

Lighting an LED

Components List

  1. LED
  2. Resistor (330 Ω (ohms))
  3. 2 - Female to male connectors
  4. 2 - Male to male connectors

Note that Board numbering is used, NOT Broadcom numbering

  1. Pin 11 (GPIO OUTPUT PIN)

  2. Pin 9 (GND)


GPIO Pinout

Refer to this diagram to understand the pins we are using

Note that Board numbering is used NOT Broadcom numbering

  1. Pin 11 (GPIO OUTPUT PIN)
  2. Pin 9 (GND)

Diagram Schematic


Diagram Scematic

Diagram Schematic

Circuit Schematic

Circuit Schematic


Description

Making use of the python RPi library and the GPIO methods, we can make a program that blinks an LED for a indefinate number of times or for a set number of times

blink.py
# Makes an LED connected to GPIO Pin 11 to blink ON and OFF indefinately
# until the user suplies a keyboard interrupt (<CTRL> + <C>)
import RPi.GPIO as GPIO
from time import sleep

outPin = 11
GPIO.setmode(GPIO.BOARD)
GPIO.setup(outPin, GPIO.OUT)

# Makes the LED blink ON and OFF in 2s


def blinker():
    sleep(1)
    GPIO.output(outPin, 1)
    sleep(1)
    GPIO.output(outPin, 0)


try:
    while (True):
        blinker()

except KeyboardInterrupt:
    GPIO.cleanup()

The link to the code is here