Jump to content
Electronics-Lab.com Community

Led brightness control by using c-program


JEP

Recommended Posts

I´m having this project where i have to develop a program that uses potentiometer through microcontroller (Aduc812) and converts it to PWM to adjust the brightness of a led. I have a start code here:

#include <Aduc812.h>

unsigned short ADC_Result;

void main(void)
   {

   
   ADCCON1 = 0xFC;
   ADCCON2 = 0x20;
   TR2 = 1;                   
while(1)
{


   ADC_Result = ADCDATA;
   ADC_Result >> 2;                     while (TF2 == 0)                  {
???
            }
         TF2 = 0;            
         P3_4 = 1;                
         RCAP2 = -ADC_Result;            while (TF2 == 0)         
            {
?????
            }
         TF2 = 0;               
         P3_4 = 0;                RCAP2 = ADC_Result - 1024;             }
   }

I would appreciate any kind of help..

Link to comment
Share on other sites


Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...