Pages: [1]   Go Down
Author Topic: PWM problems with Arduino Due?  (Read 500 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys, I recently got my hands on an Arduino Due and I'm trying to familiarize myself with the various functions and the programming.

Now, the pins 2-13 are supposed to have PWM so I tried fading-in/out LEDs from these pins. I cannot use PWM with pins 6-7, but I can use the digitalWrite to blink the LEDs in those pins.

This is the code I am running:

Code:
int j;
int del=2;
int k=1;

void setup()
{               
  pinMode(k, OUTPUT);


void loop() {
  for(j=0; j<=256; j++)
  {
    analogWrite(k, j);
    delay(del);
  }


  for(j=256; j>=0; j--)
  {
    analogWrite(k, j);
    delay(del);
  }
}

Am I doing something wrong? Is it possible that the board is defective?  Or perhaps that I've managed to somehow damage it?

« Last Edit: June 08, 2013, 12:15:35 pm by Persuader » Logged

Michigan
Offline Offline
Newbie
*
Karma: 1
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

shouldn't int k = 6 or 7?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah, yes, indeed I manually changed the code to all the numbers from 2-13 manually to see which of the pins where not working.
I actually discovered the issue when I tried to fade in/out LED from pins 13-5 with a for loop, then I noticed that the loop stuck at  LED7 every time, I then removed the for and changed variable k manually.
Logged

Pages: [1]   Go Up
Jump to: