Pages: [1]   Go Down
Author Topic: digitalWrite following analogWrite  (Read 424 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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

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. 

* brutusbot_cmd_sharp.zip (2.64 KB - downloaded 5 times.)
Logged

Pages: [1]   Go Up
Jump to: