Go Down

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

DEAFBOY

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