1

In the following code I am trying to use pwm to control contrast of a Character LCD. I have been reading this page. http://raspi.tv/2013/how-to-use-soft-pwm-in-rpi-gpio-pt-2-led-dimming-and-motor-speed-control

white = GPIO.PWM(25, 100)    # create object white for PWM on port 25 at 100 Hertz  
red = GPIO.PWM(24, 100)      # create object red for PWM on port 24 at 100 Hertz  

white.start(0)              # start white led on 0 percent duty cycle (off)  
red.start(100) 

My question is how to implement something like this into my code.

Here is the code I have. For the record I did not write parts of this but I am unsure who to give credit to.

https://github.com/jamesmc1120/PB/blob/58ac35e217d2623ab4cf937ac30fa06f32d07d82/start.py

  • Have you researched PWM? The problem may be you are not comfortable with programming. Why not try and see? – joan May 23 '17 at 6:36
  • I have researched pwm. I even put a link to one of the pages i was ready about pwm. I am certainly still an amateur at programming. I have tried getting this to work but was unable to which is why i am asking a community of experts. – user3708579 May 23 '17 at 13:27
1

Dimming the back light of an LCD is not as straight forward as dimming simple LEDs. A lot depends upon the specific LCD you are using and the specific circuitry it is attached to. Without the specifics of the LCD you are using, it is not possible to give a specific answer.

Some LCDs have a pin that can be used to adjust the back light brightness. Typically this is done using a variable resister to control the voltage level applied to the back light LED. However, it can also be done by PWM, but typically requires a transistor and resister. The RPi is then used to control the transistor which adjusts the current flow to the LCD back light pin. This all assumes the circuitry for the LCD isn't hardwired to a set brightness level.

Doing a simple web search on "Raspbery PI LCD dimmer" and the name of your LCD (i.e. 1602) should get you detailed options for your specific LCD.

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.