Your shopping cart is empty!
Raspberry Pi: LED Blinking using Python
- Idris Zainal Abidin
- 26 Feb 2026
- Tutorial
- Beginner
- 2900
Introduction
LED blinking is the first lesson for most microcontroller/electronics starters. Same as Raspberry Pi, the GPIO pins on a Raspberry Pi are a great way to interface physical devices like buttons and LEDs with the little Linux processor. The first lesson should be easy to start. So, for this tutorial, I will use serial command line, no LCD monitor, no web browser and GUI. For programming, I will use Python.
Note: Original Published 21 Aug 2015, Edited by Azmir Che Azmi

Hardware
- Raspberry Pi
- MakerDisk microSD Card with RPi OS
- UC00C USB to UART Converter
- USB Micro B Cable
- Raspberry Pi Power Delivery
- Breadboard
- Jumper Wire
- LED
- Resistor
Software
Assembly
Step 1: Insert the MakerDisk SD card into your Raspberry Pi, as it comes preinstalled with all the necessary Raspberry Pi drivers and software, allowing you to get started immediately without additional setup.
Step 2: Download PuTTY and open it (Note: no installation required). Connect UC00A to PC and it should be detected as COM port. Set your COM number and baudrate to 115200 bps. Click Open.

Step 3: Connect UC00C’s transmit, receive and ground pins to Raspberry Pi.

Step 4: Connect LAN cable to Raspberry Pi (internet is a must) and power it up. Wait until boot complete. Default login is pi and raspberry for password.

Step 5: It is better to update and upgrade the Raspberry Pi first. Type:
sudo apt-get update sudo apt-get upgrade
Step 6: Then install Python and Raspberry Pi RPi.GPIO Python library. FYI, the newest version of Raspbian has the RPi.GPIO library pre-installed. Type:
sudo apt-get install python-dev sudo apt-get install python-rpi.gpio
Step 7: Ok now lets proceed with LED blinking. Connect the LED (to gpio-23) and 330Ω resistor as shown below. You can refer to this link for Raspberry Pi GPIO numbers.

Step 8: Create new python file, LED_Blinking.py. Type:
sudo nano LED_Blinking.py
Then write the following code. When complete press CTRL+X and then Y.
To run the code, type:
sudo python LED_Blinking.py
Now, your LED should blinking at 500ms. To terminate the program press CTRL+C.
Step 9: How about controlling the LED using a switch? Lets try. Connect switch to gpio-24 as shown below.

Step 10: Repeat step 8 to edit the code. Then run the code and test it.

REFERENCES
Credit to:
- Raspberry Pi: Python scripting the GPIO by scottkildall
- Raspberry Pi GPIO by Jimbo
- Tutorial: Raspberry Pi GPIO Pins and Phyton by Mark Kleback
Thank you
Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiries, please post at Telegram group.
Was this helpful?    [   Yes ] [   No ]
Hardware Components
UC00C (CH340) USB to UART Converter
S$5.36 S$5.36
Raspberry Pi 4 Model B - 8GB
S$180.00 S$180.00
Raspberry Pi Approved MakerDisk microSD Card wi...
S$25.00++ S$25.00
Raspberry Pi 5 USB-C PD (Power Delivery) 27W PSU
S$18.41++ S$18.41
International
Singapore
Malaysia
Thailand
Vietnam
