1

I am new to the GPIO on Raspberry Pi and I'm trying to control the ACT LED (GPIO #47) on Raspberry Pi Model B+.

GPIO.output(47,GPIO.HIGH)

This python command just makes the ACT LED blink. I can keep it always high(on) using a while loop but I have to interrupt(ctrl+c) to exit the program. Is there a way in which I can turn the ACT LED on(not blink) and exit the program normally (without external interruptions) without turning it off.

asked Jun 27, 2016 at 20:36
0

2 Answers 2

1

I think what's happening is that you are turning the LED on, but then the LED resumes it's normal behavior of turning on and off with SD card activity. You need to remove this binding to the SD card activity so that your program can turn it on and off and it will stay that way. The best and easiest way to do this is with a bash script, although I am sure you can use the OS commands from within Python.

Look here for how to break the binding, and then you can turn the LED on and off as you please. You can even return the LED to SD card activity when you are done.

Basically, there's a file (location may change with which version of which OS you are running) that contains the "trigger" for the LED. Typical triggers are hard drive, SD card, USB and ethernet activity, "always on", and even "heartbeat." Change it to "none," then nothing will interfer with your Python or bash script when controlling the LED.

answered Jun 27, 2016 at 21:25
3
  • 1
    Or just put dtparam=act_led_trigger=none in /boot/config.txt. Commented Jun 27, 2016 at 21:33
  • This is not really an answer. This is a description of the problem and a link. <meta.stackexchange.com/questions/225370/…> Commented Jun 27, 2016 at 21:42
  • @sir_ian I summarized the solution in the last paragraph. I agree it is a little vague, but without the exact OS he is using, that's the best I can do. Commented Jun 27, 2016 at 22:14
1

You can run the job in the background by appending an ampersand (&) to the command:

python scriptname.py &

To bring the last background process to the foreground use the fg command, and kill it with ctrl+c if you have multiple background processes use the jobs command, and kill it with the job number (the number in the square brackets) kill %jobnumber.

A detailed explanation of all the ways to kill a job can be found in this question.

You can get more information on any of the commands mentioned using the man command (e.g. man jobs). Man (short for manual page) is Linux's built in help system.

answered Jun 27, 2016 at 21:01
1
  • 1
    I think this will use a lot of resources needlessly. See my answer about LED bindings. Commented Jun 27, 2016 at 21:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.