This post has been deleted and is no longer viewable
I am trying turn to an LED on and off on my breadboard with my Pi. I’m using the Adafruit T-Cobbler Plus to connect to my Pi 4 Model B’s GPIO pins. Im trying to use the sample code from the raspberrypi website to test the functionality but nothing happens when I run the code.
from gpiozero import LED
from time import sleep
led = LED(17)
while True:
led.on()
sleep(1)
led.off()
sleep(1)
When I run the program it does nothing and no error messages. I have tried changing the GPIO number in the “led” variable to different pins and I’ve tried connecting my wire to different GPIOs on the cobbler. Nothing seems to happen and I don’t get any error messages. The program seems to run fine .
Is there a difference between the Pi 3 and Pi 4 pinouts that make my cobbler incompatible? Is there a different program I need to use? I have no idea what to do.
Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.
Your Answer
Answer V0.1
There are 101 reasons that your little LED is not blinking as you expect:
(1) You have not used a resistor to limit the current passing through the LED (Note 1). Without this current limiting resistor, too big current would pass through the LED and fry it.
(2) You have not connected the LED in the correct polarity. The wiring should be something like this:
(a) 3.3V (Note 1) to either end of the current limiting resistor.
(b) The other, now dangling, end of resister connected to the long leg (Note 2) of LED.
(c) The short leg of the LED connected to GPIO 17 (Note 3).
Notes
Note 1 – You can use the 3.3V power pin of the Rpi’s 40 pin connector for the LED
Note 2 – Current limiting resistor is usually from 330 Ohms up to 1,200 Ohms.
Note 2 – GpioZero uses BCM numbering for GPIO pins. See Reference 3 below for more details.
Note 4 – For a LED, the long leg is the positive, anode terminal to where current comes in from positive 3.3V; the short leg is the negative, cathode terminal from which current goes out, to the GPIO pin.
References
(1) GpioZero Doc
(2) GpioZero Doc > LED > 14.1.1. LED
(3) GpioZero Doc > 2.2. Pin Numbering
This library uses Broadcom (BCM) pin numbering for the GPIO pins, as opposed to physical (BOARD) numbering. Unlike in the RPi.GPIO library, this is not configurable, …
Any pin marked “GPIO” in the diagram below can be used as a pin number. For example, if an LED was attached to “GPIO17” you would specify the pin number as 17 rather than 11.
End of answer
Categories: Uncategorized
gpio readall
but this no longer works on the Pi4 I have written a program to report pin states raspberrypi.stackexchange.com/a/106099/8697 but there are other options. – Milliways 43 mins ago