Jump to content
43oh

Recommended Posts

am having an LED fade in and out with PWM but occasionally as it's fading out it will flick erratically   I don't believe the issue is with my code but I'll post just in case. I don't know if it's a bug.

int pwmvale = 0;
void setup() {
 
pinMode(4, OUTPUT); //pin that controls the LED
}

void loop() {

 if (pwmvale == 0){
   while (pwmvale < 255){
 analogWrite(4,pwmvale);
 pwmvale++;
 delay(10);
 }
 }
 
 else{
   while (pwmvale > 0){
     analogWrite(4,pwmvale);
     pwmvale--;
     delay(10);
   }
 }
}
Link to post
Share on other sites

Try this code with the msp430g2553

int pwmvale = 0;

 

#ifdef __MSP430G2553__

const uint8_t analog_capable_pin = P1_6; /* pick one: P1_2, P1_6, P2_1, P2_2, P2_4, P2_5, P2_6 */

#endif

 

void setup() {

// analogWrite configures pin using Timer

}

 

void loop() {

 

if (pwmvale == 0) {

do {

analogWrite(analog_capable_pin, pwmvale);

pwmvale++;

delay(10);

} while (pwmvale < 255);

}

else {

do {

analogWrite(analog_capable_pin, pwmvale);

pwmvale--;

delay(10);

} while (pwmvale > 0);

}

}

Link to post
Share on other sites

Sorry Rickta59, I missed that post. I tried your code, the issue still exists (not as noticeable on the small onboard LED).  Here is a photo of the circuit, a bit blurry (my batteries for my good camera are dead atm, will post a better photo when they finish charging):

 

Img00022.jpg

Link to post
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.

×
×
  • Create New...