Go Down

Topic: Mysterious!!!!! Led Fading (Read 464 times) previous topic - next topic

Code: [Select]

int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
  }

void loop() {
  for(int fadeValue = 0; fadeValue <= 255; fadeValue++) {
    analogWrite(ledPin, fadeValue);
    delay(5);
  }
  for(int fadeValue = 255; fadeValue >= 0; fadeValue--) {
    analogWrite(ledPin, fadeValue);
    delay(5);
  }
}


Why is ledPin 13 blinking, not fading? I use Arduino UNO R3.


int ledPin = 2; -> Blink
int ledPin = 3; -> Fade
int ledPin = 4; -> Blink
int ledPin = 5; -> Fade
int ledPin = 6; -> Fade
int ledPin = 7; -> Blink
int ledPin = 8; -> Blink
int ledPin = 9; -> Fade
int ledPin = 10; -> Fade
int ledPin = 11; -> Fade
int ledPin = 12; -> Blink
int ledPin = 13; -> Blink


I'm deaf.

www.christian-elektronik.de

Grumpy_Mike

Because only 6 pins are capable of PWM outputs. That's analogWrite.
Pin 13 is not one of those pins.

http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy