Shop OBEX P1 Docs P2 Docs Learn Events
controling a RGB Led — Parallax Forums

controling a RGB Led

LEDboyLEDboy Posts: 21
edited 2009-04-22 07:32 in Propeller 1
I need some help I've been playing around with the FullDuplexSerialPlus program and a RGB Led. What I'm trying to do is us the FullDuplexSerialPlus as an input for the duty cycle of the RGB.· I would like·to be able to ajust the brightness 0 -255 of the 3 colors in order to make diffrent colors...can someone point me in the right direction. It cant be as hard as I'm making it. hahaha·

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-04-22 06:53
    Hello,

    the FDS+-onject provides a method

      PUB getstr(stringptr)
    
    
    



    with this you could receive a string containing a character "R" , "G", "B" for indicating the channel and a value
    example: "B128"

    and then use the StrToDec-method to change the string "128" into the integernumber 128

    the string has to be ZERO-terminated when using FDS+

    if you use the extended_FDSerial-object (ExFDS) there is a version where strings can be terminated with a carriage return or
    a self defined delimiter

    then in in the obex there is a PWM-object

    Dedicated pwm generator
    with a small demoprogram for that.

    attention in the CON-section of the PWM-demo you have to change the

    CON _clkmode = xtal1 + pll16x
        _xinfreq = 6_000_000             ' CHECK THIS!!! most parallax boards use  _xinfreq = 5_000_000
    
    
    



    best regards

    Stefan
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-04-22 07:32
    On a first glance it looks like "Dedicated pwm generator" is not optimal for driving the LED. Of course for playing with it it's a fast and easy solution. But I'd never use it in a serious case as you have to start 3 COGs, one for each color.
    A COG using both counters would not be enough as well. But I believe for this usecase it would be feasible to do the PWM in software. Doing a 16 bit PWM @ some kHz should be doable.
Sign In or Register to comment.