Go Down

Topic: PWM problems with Arduino Due? (Read 706 times) previous topic - next topic

Persuader

Jun 08, 2013, 06:47 pm Last Edit: Jun 08, 2013, 07:15 pm by Persuader Reason: 1
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: [Select]

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?


Paul F.


Persuader

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.

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