Click here to Skip to main content
11,797,944 members (77,613 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Embedded C
I am working on a RGB project using PWM. I need help in C- code. I want to display different colors from LED. But due to my small info of C- language it is difficult. Is there any guy can help me in writing code for it. Any sample code for it. That will be very helpful for me. By the way I am using PIC24FJ64GA002-I/SP. My specs are following Using RGB LED common anode. Pic is PIC24FJ64GA002-I/SP. Have external osc as well. Using enhancement mode Fet for switching RGB LED. Voltage supply is 3.3 from 5v regulator.

I want to display at least 256 colors from led. I need them to display at some interval which I can handle my self.

It will be very good if someone give me his sample code which I can play with. I using mplab IDE 8.86 and complier is mpalb c-30.

Posted 16-Jan-13 22:04pm
Edited 17-Jan-13 0:24am
(no name)472K
Richard MacCutchan at 17-Jan-13 6:26am
You need to study the documentation for the PIC device to see what commands and parameters it uses. Also the documentation for the mplab system.
Sergey Alexandrovich Kryukov at 17-Jan-13 6:56am
...and ask a question other than "is there any guy..."
zaphoed at 1-Feb-13 16:42pm
the following fragments may give you a hint:

int16_t iBrightness[NOF_LED] = {0, PWM_DURATION/10, PWM_DURATION/4};

int main(void) {
// init variables if any
init_IOs(); // by referring to the PIC docs
for (;;) {
modifyBrightnesses(); // calculate new values and set PWM
as richard said, the tricky part is to figure out how you can configure the hardware to do the needed initializations and change the PWM(s)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 575
1 Maciej Los 375
2 OriginalGriff 353
3 Abhinav S 342
4 Richard MacCutchan 218
0 OriginalGriff 2,150
1 Maciej Los 1,790
2 KrunalRohit 1,456
3 CPallini 1,415
4 Richard MacCutchan 1,016

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100