Go Down

Topic: digitalWrite following analogWrite (Read 556 times) previous topic - next topic

freeze

I am new to the Due. Here is my question:
The following code blinks an LED using the Uno board, but not with the Due.

int led = 9;
void setup() {               
  pinMode(led, OUTPUT);     
}

void loop() {
  analogWrite(led, 220);
  delay(1000); 
  digitalWrite(led, LOW);
  delay(1000); 
}

However, the following works with both boards:

int led = 9;
void setup() {               
  pinMode(led, OUTPUT);     
}

void loop() {
  analogWrite(led, 220);
  delay(1000); 
  analogWrite(led, 0);
  delay(1000);   
}

Does the Due not allow a call to digitalWrite if analogWrite has already been called?

freeze

The reason I ask this question is that such behavior is not only non-intuitive, but also breaks many lines of useful existing code. See the attachment for an example of motor driving code (for the Solarbotics Brutusbot robot) that works for the Uno board, but not for the Due board.

I have modified the robot code successfully. But this behavior of the analogWrite() and digitalWrite() seems to be a serious problem that should be addressed. 

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