Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4626

Troubleshooting • Raspberry Pi pin not toggling regularly (Zero 2W)

$
0
0
Good day to all!

Got this Freenove Breakout Board for Raspberry Pi. (https://store.freenove.com/products/fnk0080)

The idea was simply to test that the GPIO pins all functioning correctly by toggling them.

Wrote a simple python program that goes through all of the pins in a while True loop:

Code:

import RPi.GPIO as GPIOimport time# Set up GPIO using BCM numberingGPIO.setmode(GPIO.BCM)GPIO.setwarnings(False)# Get the total number of GPIO pinsLED_pins = [2, 3, 4, 17, 27, 22, 10, 9, 11, 5, 6, 13, 19, 26, 14, 15, 18, 23, 24, 25, 8, 7, 12, 16, 20, 21]  # Raspberry Pi 4 has 40 GPIO pins#GPIO4 is problematic!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!# Set up all GPIO pins as outputsfor pin in LED_pins:    GPIO.setup(pin, GPIO.OUT)    # Set up all GPIO LOWfor pin in LED_pins:    GPIO.output(pin, GPIO.LOW)  # Turn off the pintry:    # Loop through each GPIO pin and toggle it on and off    while True:        for i, pin in enumerate(LED_pins):            GPIO.output(pin, GPIO.HIGH)  # Turn on the pin            time.sleep(0.1)  # Wait for a short duration            GPIO.output(pin, GPIO.LOW)  # Turn off the pin            time.sleep(0.1)  # Wait for a short durationexcept KeyboardInterrupt:    # Clean up GPIO    for pin in LED_pins:        GPIO.output(pin, GPIO.LOW)  # Turn off the pin
Everything works as expected (always a nice feeling), but what I noticed is that the GPIO4 pin after one or two iterations stops working.
If I restart the program again, it works a couple of times then stops.

This was tested on a Raspberry Pi Zero 2W running Bullseye image.
Will try the same test on a RPi 4 to see what happens there.

Any ideas why is this happening? To me it does not look like it is an electrical problem.

Many thanks for your time and help!

Statistics: Posted by ajevtic — Sun May 05, 2024 11:16 am — Replies 3 — Views 68



Viewing all articles
Browse latest Browse all 4626

Trending Articles