Different loops in scheduler using the same pin

Hi,

I am new to the ARM world, and just started using a Due today.
Is it possible for two different loops in the scheduler to call upon the same pin?
For example:
loop1(){
digitalWrite(13,HIGH);
delay(100);
digitalWrite(13,LOW);
delay(100);
}
loop2(){
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
}

That's a little bit of an extreme case. But even if I wrote my sketch so that it wouldn't allow a pin to be set high and low at the same time, would the Due handle that?

Thanks

Any part of your code can write to any pin whenever it likes. It's up to you to write code that does so in a meaningful way.

the scheduler

What scheduler?


Rob

I don't think the Arduino environment has any multitasking on the Due, beyond
interrupts. Or have I missed something (I'd guess the support is probably there in
libsam anyway).

Graynomad:
Any part of your code can write to any pin whenever it likes. It's up to you to write code that does so in a meaningful way.

the scheduler

What scheduler?

@Rob Maybe I'm not using the right name for it, but here is the reference page: Scheduler - Arduino Reference

MarkT:
I don't think the Arduino environment has any multitasking on the Due, beyond
interrupts. Or have I missed something (I'd guess the support is probably there in
libsam anyway).

@MarkT I don't know if it's true multitasking (I wouldn't know how to tell) But the 'Multiple Blinks' example shows that you can have two functions run simultaneously. http://arduino.cc/en/Tutorial/MultipleBlinks

Maybe I am just not understanding it correctly... Please excuse my non-EE background

Yes OK, I was not aware that there is a scheduler library, your terminology is correct.

Anyway my comment still stands, you can write to a pin whenever you want from wherever you want, it's up to you to get it right that's all. In that 'Multiple Blinks' example you could have all three loops write to the same pin/LED, what it would look like is anyone's guess but it would work.

two functions run simultaneously

They don't run "simultaneously", it might appear that way to a human but a CPU can only do one thing at a time.

Do you have a specific application that need two processes to control the same pin?


Rob

I didn't have any specific project in mind. I was playing the around with my new Due, and was curious how far I could push it.
Though, if I do try making something like this, I'll post either my success or failure. :slight_smile:

Thanks for the help!