Can you guess what this code does on a Due?

No fair trying it out first!!!

void setup() {

}

void loop() {
  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
  delay(500);
  
  pinMode(13, INPUT);
  
  delay(500);
  
}

I suspect it does almost the same as your other post but on a different pin? Just a wild guess......

Regards,

Graham

Ouch!

I suspect it does almost the same as your other post but on a different pin? Just a wild guess......

Sorry, my question was well intended as, for the life of me, I can't understand why it does blink the LED "L" on pin D13. Why does the statement "pinMode(13, INPUT);" cause LED on D13 to light?

Also causing confusion to me why is the quiescent condition of LED L "ON"? (the answer is most likely related to the previous question).

void setup() {

}

void loop() { while(1);

}

What is the power up state of the digital ports on the DUE? BTW I have DUE R3 and I believe iti is one of the first ones made.

Sorry to waste everyone's time.

David

Found one of the answers to "Also causing confusion to me why is the quiescent condition of LED L "ON"?" in this posting:

http://forum.arduino.cc/index.php?topic=283322.msg1993422#msg1993422

It seems that since the DUE is initialized to input on all digital ports and they are pulled up automatically, then the LED L (on D13) circuit [the LED is driven by an non-inverting unity gain opamp] will see a high and light up!

OK got that now I can go back to sleep!

Thanks

David G.

All questions are good questions..... But to ask the exact same question just substituting for a different pin was a little unnecessary was what I was trying to say.

Keep asking and keep learning! :grin:

Regards,

Graham

Graham,

But to ask the exact same question just substituting for a different pin

My bad, I was hoping folks would be struck by the code (the two are a little different) and wonder what it would do (it does make the LEDs blink). and dash off a response explaining why the LEDs were blinking!! because I really did not understand why.

I put both examples together below:

//made the two delays different so one can see which statement is doing what to the LEDs 

void setup() {

}
//connect a led from pin 12 (anode) to ground (cathode)
void loop() {
  pinMode(12,OUTPUT); // observe--LED pin 12 on for 500mS
  pinMode(13,OUTPUT);
  digitalWrite(13,LOW); //observe--LED L (D13) off for 500 mS --Comment this line out and LED L does NOT flash
  delay(500);
  
  pinMode(12, INPUT);  //observe--LED on pin 12 off for 2000 mS
  pinMode(13, INPUT);  //observe--LED L (D13) on for 200mS
  delay(2000);
  //while (1);
}

Best regards

David G.