Professional Documents
Culture Documents
Can We Control The On-Board Leds - Page 2 - Raspberry Pi Forums
Can We Control The On-Board Leds - Page 2 - Raspberry Pi Forums
Hardware
Software
Documentation
News
Forums
Foundation
If you want to control the on-board 'ACT' LED, then here is a quick way:
Get wiringPi:
gordon@drogon.net
-Gordon
--
Gordons projects: https://projects.drogon.net/
Clearing or setting the green led is already documented, so I won't cover that here.
Clearing the led's that are flickering at ethernet access can be done by modifying a few lines of kernel code.
In drivers/net/usb/smsc95xx.h you will find the code:
I have also tried to reprogram the gpio pins from user space (with and without using libusb), but somehow it
doesn't work; I find that, even after recompiling the kernel so it uses smsc95xx as a kernel module, and unloading
this module, the device 0424:ec00 can be opened, even claimed, but writing the LED configuration with the
usb_control_msg returns error -32 EBUSY, signalling that somehow the chip isn't accepting that control message.
With a solution from userspace I mean a program that writes the correct values to the low level registers to
control the leds without patching the kernel.
cat /sys/class/leds/led0/trigger
none [mmc0] timer oneshot heartbeat backlight gpio cpu0 default-on rfkill0 phy0rx phy0tx ph
y0assoc phy0radio
Android app - Raspi Card Imager - download and image SD cards - No PC required !
ragnarjensen
- Code: Select all
Posts: 332
/* Joined: Wed May 15, 2013 6:13
* This is free and unencumbered software released into the public domain. pm
* Location: Stockholm, Sweden
* Anyone is free to copy, modify, publish, use, compile, sell, or Contact: +
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
* software to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and
* successors. We intend this dedication to be an overt act of
--
Ragnar
--
Ragnar
Save as actledPi.c
Then build it:
ragnarjensen
- Code: Select all
Posts: 332
gcc -Wall -O3 -o actledPi actledPi.c Joined: Wed May 15, 2013 6:13
pm
Location: Stockholm, Sweden
Contact: +
Put the binary somewhere in the PATH, I put it in /usr/local/bin:
sudo actledPi -d
/usr/local/bin/actledPi -d
in /etc/rc.local, just before the last line, that says "exit 0", to have it start automatically at boot.
--
Ragnar
With the Raspberry Pi model B+, a program I had that used GPIO16 to drive the STATUS OK LED on the
Raspberry Pi model B no longer works. Given that GPIO16 is now exposed on pin36 of the 40-pin header, I'm
not too surprised. However, this does beg the question: besides writing to /sys/class/leds/led0/brightness, how tonyhansen
can I drive the STATUS OK LED on the B+ using the GPIO interface?
Posts: 17
Joined: Sat Jan 03, 2015 6:20 am
True! On a A+ and B+ the status ACT LED is now controlled by GPIO47, and its actually controlling a FET, so
on/off is now inverted, with high being ON!
mahjongg
Forum Moderator
In fact you can now also sense the status of the PWR LED, that is the brownout detector driving it, by using
GPIO35 to read it out, but if you change GPIO35 to an output you can actually control the PWR LED now too,
same way as the ACT LED. Posts: 14208
Joined: Sun Mar 11, 2012 12:19
am
Location: South Holland, The
Netherlands
. tonyhansen wrote:
DougieLawson
With the Raspberry Pi model B+, a program I had that used GPIO16 to drive the STATUS OK LED on the
Raspberry Pi model B no longer works. Given that GPIO16 is now exposed on pin36 of the 40-pin Posts: 41883
header, I'm not too surprised. However, this does beg the question: besides writing to Joined: Sun Jun 16, 2013 11:19
pm
/sys/class/leds/led0/brightness, how can I drive the STATUS OK LED on the B+ using the GPIO interface?
Location: A small cave in deepest
darkest Basingstoke, UK
Change your code to use GPIO47. Contact: + ,
mahjongg, thank you for the complete response, along with the additional information on controlling the other
status LED.
tonyhansen
Posts: 17
Joined: Sat Jan 03, 2015 6:20 am
mahjongg
Forum Moderator
Posts: 14208
Joined: Sun Mar 11, 2012 12:19
am
Location: South Holland, The
Netherlands
. Geekmason wrote:
Hitechcomputergeek
I'm not sure, but I it looks like this thread (or rather its intrepid participants) may be able to solve a riddle I
have concerning the onboard LEDs. See my questions here: http://www.raspberrypi.org/phpBB3/viewt ... Posts: 28
83#p366483 Joined: Wed Nov 27, 2013 4:29
am
I was hoping to "recreate" an ACT(ivity) LED off one of the GPIO pins so I can mount it to the exterior of a
custom case. Doable?
Not sure about this, but could you set the trigger for the other GPIO pin to mmc0 using /sys/idk/trigger?
This is excellent information. I managed to add 2 additional LED instantiations in the board support kernel file to
control the additional LEDs that we're using for our system. Much less hassle than instantiating the GPIO in our
control program.
ConnersJM
For the trial-run I set them to cpu0 to show activity, but I'll change them to trigger on gpio. Then they're controlled
by changing the brightness between 0 and 1<=x<=255. I don't see any difference in brightness when I tested, but
I suppose they could be PWMed to control brightness. Not sure if this was the intent. Does anyone know?
-Jeremy
actledPi and hddledPi on another post, Custom Case indicator LEDs, run successfully on *Raspbian(OSMC) but
not on **ArchLinux(RuneAudio).
To run actledPi on GPIO connected LED:
On Pi3, dtoverlay=pi3-act-led,gpio=n must be appended to config.txt .
* compiling failed on error: usb.h, $ sudo apt-get install libusb-dev fixed it.
** ArchLinux compiling complained about missing braces at ... if (current == on) ...
.LedInit:
LDR R1,GPIOBase
LDR R0,#1 SHL #21
STR R0,[R1,#16]
MOV R15,R14
.LedOn
LDR R1,GPIOBase
LDR R0,#1 SHL #15 ;Turning on the GPIO controling the LED.
STR R0,[R1,#32] ;Write the GPIO Set Register.
MOV R15,R14 ;Return to caller.
Assuming you are running on the ARM, and on a RPi B+/2B/3B. A bit different if you are running on the
VideoCore IV, though same basic concept.
. DavidS wrote:
DougieLawson
You're replying to a post from Thu 26 Jul 2012 @ 21:19 by someone who hasn't visited the forum since Thu 05
Feb 2015 @ 12:46.
Posts: 4340
. DavidS wrote: Joined: Thu Dec 15, 2011 6:39
am
Location: USA
. simplesi wrote: Contact: +
Simon
You're replying to a post from Thu 26 Jul 2012 @ 21:19 by someone who hasn't visited the forum since
Thu 05 Feb 2015 @ 12:46.
Ooops
In this case I can well imagine someone new here having the same question. Having googled it, as people always
suggest they should, they may end up here. At which point a recent post with a new or better solution, or a post
pointing out that perhaps the old solution don't work anymore due to whatever hardware software changes, is not
a bad thing.
In short questions don't become invalid just because they are old or the original poster has disappeared.
. Heater wrote:
DougieLawson
In short questions don't become invalid just because they are old or the original poster has disappeared.
Posts: 41883
Yes they do, because the RPi3B hardware is just a little bit different to the RPi1B and code that works on a 3B Joined: Sun Jun 16, 2013 11:19
pm
won't run on a 1B.
Location: A small cave in deepest
darkest Basingstoke, UK
Contact: + ,
Languages using left-hand whitespace for syntax are ridiculous
Display posts from previous: All posts * Sort by Post time * Ascending * Go
Follow us
Sign up to newsletter
YouTube
About Raspberry Pi
News
Contact us
Trademark
About us
Accessibility
Cookies
Licensing
Privacy
Security
For Industry
Powered by Raspberry Pi
Design Partners
Hardware
Add-on boards
Cases
Peripherals
Software
Raspberry Pi OS
Raspberry Pi Imager
Raspberry Pi Desktop
Documentation
All categories
Datasheets
Forums
All forums
Raspberry Pi Store
Cambridge Store
Raspberry Pi Press
The MagPi
HackSpace
Wireframe
Custom PC