• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Turn the Camera Flash LED on and off!!

Lars

Android Expert
Mar 24, 2010
1,439
210
www.larsdennert.com
If you have root here is a way to turn the Camera LED on and off for a real flashlight app. No working widget but it is based on the Desire hardware exploit from Damunix which I've adapted for the Incredible. I'm using superuser.apk but I think the unregulated su sticky method should work too.

Install Gscript from the market, or a terminal app if you are a glutton for typing punishment every time.
In Gscript select Menu - Add Script
Name: LED On
Needs SU checked and obviously Gscript has to be granted SU.
Body: echo 125 > /sys/devices/platform/flashlight.0/leds/flashlight/brightness
Save it off and select Menu - Add Script again
Name: LED Off
Needs SU checked
Body: echo 0 > /sys/devices/platform/flashlight.0/leds/flashlight/brightness
Save that one off

Run LED On to turn it on and LED Off, well you get it. Now we just need a stand alone app that runs in SU to clean it up. In any case this is much better than the $1 app in the Market that crashes the camera and requires a reboot.
 
If you have root here is a way to turn the Camera LED on and off for a real flashlight app. No working widget but it is based on the Desire hardware exploit from Damunix which I've adapted for the Incredible. I'm using superuser.apk but I think the unregulated su sticky method should work too.

Install Gscript from the market, or a terminal app if you are a glutton for typing punishment every time.
In Gscript select Menu - Add Script
Name: LED On
Needs SU checked and obviously Gscript has to be granted SU.
Body: echo 125 > /sys/devices/platform/flashlight.0/leds/flashlight/brightness
Save it off and select Menu - Add Script again
Name: LED Off
Needs SU checked
Body: echo 0 > /sys/devices/platform/flashlight.0/leds/flashlight/brightness
Save that one off

Run LED On to turn it on and LED Off, well you get it. Now we just need a stand alone app that runs in SU to clean it up. In any case this is much better than the $1 app in the Market that crashes the camera and requires a reboot.

Nice work man! Having options is always great so even though there are other apps on the market that may or may not do the same, dont shy away from making scripts like you did above. Some people may find your script better, or maybe it will work better on their device vs other apps out there.

Good work!
 
Upvote 0
Echo not found errors for me... verified that I didn't mistype and su access is granted.
echo may need to be in lower case. Linux is a case sensitive OS.

Lamppu doesn't seem to crash my camera but I'll keep trying (to crash it :) ) Yea 255 tells it just to flash. Lamppu is able to sustain the brighter mode. Maybe that's what crashes the camera after a bit?

Thanks for the props BTW.
 
Upvote 0
lamppu does not use the brighter one, i wrote a small script to loop the "255" command, it works, and also works while using the camera. however, it flickers a bit, but the main problem is that the LEDs get VERY HOT when left on 255. also i cant figure out how to turn it off short of restarting the phone.
I'd like to test out that loop on my phone. Would you mind posting the script or sending a PM?

Thanks :)
 
Upvote 0
lamppu does not use the brighter one, i wrote a small script to loop the "255" command, it works, and also works while using the camera. however, it flickers a bit, but the main problem is that the LEDs get VERY HOT when left on 255. also i cant figure out how to turn it off short of restarting the phone.

Yikes, LED's generally shouldn't get very hot...if they are that means there is far too much voltage flowing into the diode. If running 255 makes the LED hot, chances are you want to not use that value or you may kill the diode
 
Upvote 0
sure, heres the script. USE AT YOUR OWN RISK.

Code:
while true; do
  out=`echo 255 > /sys/devices/platform/flashlight.0/leds/flashlight/brightness`
  done


this does continue to loop while the camera is on, but i wouldnt recommend it.

Probably uses a significant amount of cpu time too to constantly write out 0xFF to that port lol, not to mention no "nice" way to end the script
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones