Pages: [1]   Go Down
Author Topic: Mysterious!!!!! Led Fading  (Read 295 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Jr. Member
**
Karma: 1
Posts: 55
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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


Logged


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31540
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: