Pages: [1]   Go Down
Author Topic: arduino has main function...???  (Read 1929 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi all,
        i have arduino mega 2560 development kit. i m new for this hardware. i want to know when we programming in arduino ,so can we define a function which name is main like 8051 or other controllers.
coz in this i saw the loop & setup functions... so my questions is. can we have permission to access in to main function coz without main function "C" code doesn't work.

if we can access to main function then plz anyone give a code like this format.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49034
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When you compile a sketch, a main() function is created. The init() and setup() functions are called, and then loop() is called in an endless loop.

What is it that you want to do in main() that can not fit in setup() or loop()?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 299
Posts: 26195
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, there is a "main", but it isn't clear to me why you need access to it.
Code:
int main(void)
{
init();

setup();
    
for (;;)
loop();
        
return 0;
}

You provide "setup" and "loop".
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks to all  for your support ....

actually when i start, so i had an query that why i asked this.
Logged

Pages: [1]   Go Up
Jump to: