0

I have a RGB LED connected to the Pi's GPIO pins as stated on the code below. For this simple script, the GPIO18 pin is connected to the RED Led and to activate it it must be set to 0.

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM) #Usar indice do GPIO em vez do indice dos pinos

GPIO.setup(18,GPIO.OUT) #Ativa GPIO18 como saida - LED R
GPIO.setup(23,GPIO.OUT) #Ativa GPIO23 como saida - LED G
GPIO.setup(24,GPIO.OUT) #Ativa GPIO24 como saida - LED B

GPIO.output(18,False)
time.sleep(10)
GPIO.cleanup()

When I run it, the script does as intended, the Red LED lights on for 10 seconds and then lights off.

Although, when I run the script I immediately get the message "The system is going down for system halt NOW!" and as soon as the script does it's things, the Raspberry Pi shuts down.

This happens with every script that deals with GPIO pins. I've checked if everything is correctly wired a million of times and it is. I've also tested each LED connectivity individually and everything is working fine.

What do you think might be the problem?

EDIT: I should mention that every script has worked flawlessly before without this problem.

  • Does the same happen if you use the Green LED (GPIO 23) rather than GPIO 18? – joan Dec 30 '15 at 19:54
  • Yes it does. I just changed up the GPIO pins to which I connect the LEDs and it works, but I keep ignorant about what might be causing this on the original GPIO pins, – Diogo Magalhães Dec 30 '15 at 20:09
  • I am not sure what you are saying. Does the script still cause a shutdown? – joan Dec 30 '15 at 20:18
  • 1
    Most of the time when the Pi shuts down unexpectedly when using GPIO it is because you have a short. Check all of your connections again, and make sure no wires are directly connected to ground or anything like that. – Patrick Cook Dec 30 '15 at 20:18
  • Can we see some pictures of your wiring and connections? – Steve Robillard Dec 30 '15 at 23:10
0

I figured out what the problem was.

I have a PiTFT and when configuring it I set the GPIO23 as a shutdown pin, that's what was causing it.

  • Since your solution works I would recommend marking it as correct. – Darth Vader Apr 3 '16 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.