How to connect an led light to raspberry pi

This article is here to show you how to add an led to any of your raspberry pi projects. It is very simple and only takes a few minutes. If your pi is new and fresh out of the box, follow my Quick setup guide.

What you will need

Step one: Wire the connections

  • Following the wiring diagram above, make all the connections between your pi and the LED:
  • 1) Connect one side of the LED to a gpio (I used 24 for this example)
  • 2) Connect the opposite side of the LED to a ground connection on the pi

Step two: Write code to turn the LED on and off

  • Copy my LED-ON example to your pi: wget
  • Copy my LED-OFF example to your pi: wget
  • Change the permissions on the files so they can be executed: sudo chmod 777; sudo chmod 777
  • ./
  • ./