I have Python code that has run for a long time on RPis using Jessie to control an Adafruit PiTFT. I dim the screen in that code by adjusting PWM on pin 18 - works fine. I just recently built an instance of the system on the latest Raspbian which is Stretch. Now the dimming seems to simply not work. No error messages that I can see - just no effect of the code. The code itself is about as simple as it could be and it all runs as root so it should not be permission related. I'm running what seems to be the latest wiringpi library. Has anyone seen anything that might provide a clue on where to look for the cause of this?

  • 1
    Perhaps audio is enabled by default in /boot/config.txt and needs to be disabled with the later image?
    – joan
    Sep 7, 2017 at 6:55

1 Answer 1


After a lot of digging I sorted this out. Sometime in later Jessie the backlight function was added to /sys/class as the way to control the backlight on or off. It used to be that the Adafruit instructions just had you make sure the on/off pin was disabled and then the pin 18 PWM would dim the screen. However, the old way of disabling that on/off function (export 508 . . .) no longer works so now you need to do it via writing a 0 to /sys/class/backlight/soc:backlight/brightness. Once you do this then you can use the PWM function via pin 18. Perhaps eventually someone will also abstract that into the newer mechanism but for now you have to do it half one way and half the other. Hope anyone else who bumps into this finds this short thread.

Your Answer

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

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