setup() statement query ???

Hello forks.......

I am Aamir Attar and i am an Embedded developer. I am doing my project based on IOT using PIR motion sensor and came across 1 doubt which i hope that u guys will help me with that.......

(?) is it possible to use two "setup ()" statements in one program ???
(?) if yes...then hw to use it ???

"i think it can be used as nested loops or something...if i m nt wrong !!!"

Thanks in advance !!!!

Aamir_Attar:
(?) is it possible to use two "setup ()" statements in one program ???

No, each function must have a unique name.

Why would you even want two setup() functions?

Aamir_Attar:
(?) if yes...then hw to use it ???

If you really want one:

void setup() {
  // put your setup code here, to run once:
  setup2();  // run the setup2 function
}

void setup2() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

Thanks pert for your reply....

Aamir_Attar:
Thanks pert for your reply....

I am still intrigued as to why you would want/need two setup() functions.

When combining two existing sketches?

MarkT:
When combining two existing sketches?

That occured to me but there was no corresponding question about having two loop() functions