The document describes how to blink an LED connected to a Raspberry Pi by using a Python program. It outlines the necessary components including an LED, resistor, and jumper cables. It then explains how to configure the circuit by connecting the cathode of the LED to ground, anode to a resistor, and resistor to GPIO pin 17. Finally, it provides the Python code to import GPIO and turn the pin on and off to blink the LED, and discusses how to write and execute the Python program.
1 of 6
Download to read offline
More Related Content
Raspberry pi tutorial #1
1. 1
Raspberry Pi Tutorial #1
- Blink the LED -
Dong Ho Son
POSTECH
Pohang, Korea
donghoson@postech.ac.kr
2. 2
Turning on the LED - Overview
? Necessary Components
? Raspberry Pi
? 1 x Breadboard
? 1 x red LED
? 1 x Resistor
? Jumper cables
Anode
Cathode
Power rails
Terminal strips
3. 3
Turning on the LED ¨C Circuit Configuration
? Ground pin ? the cathode of the LED
? The anode of the LED ? a ballast
resistor
? The ballast resistor ? the pin GPIO 17
Ground
GPIO 17
AnodeCathode
4. 4
Turning on the LED - Python
? Import RPi.GPIO as GPIO
? Import Python GPIO module
? GPIO.output(pin, GPIO.HIGH)
? Turn on the LED
? time.sleep(1)
? Delay for 1 second
? GPIO.output(pin, GPIO.LOW)
? Turn off the LED
? GPIO.setmode(GPIO.BCM)
? GPIO.setup(17, GPIO.OUT)
? Select GPIO #17 as output pin
5. 5
Turning on the LED ¨C Program Writing & Execution
? Python Programming using Text editors
? Desktop Graphical Editors ¨C LEAFPAD, IDLE, GVIM
? Command-Line Editors ¨C NANO, VI, VIM, EMACS
? Python Programming Interpreter
? Built-in Interpreter provided in Raspbian
? Command line execution: ¡°$ python program.name¡±
6. 6
Turning on the LED - Result
? The LED is blinked!
Ground
GPIO 17