Example Code for Raspberry Pi - GPIO Blinking

Last revision 2025/12/19

This example uses the on-board LED for LED blinking demonstration.

Hardware Preparation

Wiring Diagram

Attach the terminal block expansion hat to the Raspberry Pi.

Sample Code

import time
from traceback import print_list
import RPi.GPIO as GPIO

pin_list=[4,27,21,13,26,23,22,12,20,19,24,25,16,5,6,17,18,10,9,11,8]
GPIO.setmode(GPIO.BCM)
GPIO.setup(pin_list,GPIO.OUT)
GPIO.setwarnings(False)

while True:
  GPIO.outp(pin_list,GPIO.LOW)
  time.sleep(0.5)
  GPIO.output(pin_list,GPIO.HIGH)
  time.sleep(0.5)

Result

GPIO LED.mp4

Was this article helpful?

TOP