Shop OBEX P1 Docs P2 Docs Learn Events
PWM for LCD contrast. — Parallax Forums

PWM for LCD contrast.

FORDFORD Posts: 221
edited 2012-10-18 15:11 in Propeller 1
Hi All,

I read on the forum somewhere about using PWM and a counter to adjust the contrast on an LCD, using a simple resistor and cap.

I have no problems with the hardware side, and have searched everywhere for an example for the counter setup, but cant find anything that makes it clear enough for me in these early days of using a prop.

Can anyone point me to some sample code to provide an adjustable PWM on i/o pin 13, using CTRA please ?
I would like to be able to adjust a variable that will simply change the PWM as a square wave, nothing fancy required (I dont think anyway).

Any help would be appreciated, I have tried to help myself but I get bogged down with the technicalities in the manual.

Cheers,
Chris

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2012-10-18 07:56
    FORD wrote: »
    Hi All,

    I read on the forum somewhere about using PWM and a counter to adjust the contrast on an LCD, using a simple resistor and cap.

    I have no problems with the hardware side, and have searched everywhere for an example for the counter setup, but cant find anything that makes it clear enough for me in these early days of using a prop.

    Can anyone point me to some sample code to provide an adjustable PWM on i/o pin 13, using CTRA please ?
    I would like to be able to adjust a variable that will simply change the PWM as a square wave, nothing fancy required (I dont think anyway).

    Any help would be appreciated, I have tried to help myself but I get bogged down with the technicalities in the manual.

    Cheers,
    Chris

    Hi Chris,

    Just use a 220R resistor from the pin to the LCD and a 0.1uF cap to ground on the LCD. This is the bit of code you need and this one assumes it's a 7-bit value being passed to it.
    pub contrast(n)                 ' 00..$7F
      dira[cont]~~
      ctra := %00110<<26 + cont
      frqa := n<<25
    
  • FORDFORD Posts: 221
    edited 2012-10-18 15:11
    Thank you heaps Peter,
    very much appreciated, and I'm sure many others will benefit from this as well.

    cheers,
    Chris
Sign In or Register to comment.