Hello~ I'm arduino beginner in Korea.
My book says 'void setup' is a structure for initialize variables, pin modes, start using libraries, etc. And 'void loop' is a structure for main function.
After read that, I have some wonder, so i tried below codes.
void setup
{
//none
}
void loop
{
pinMode(13, OUTPUT); //I put it here
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
void setup
{
//none
}
void loop // Delete 'pinMode(13, OUTPUT)'
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
void setup
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
void loop
{
}
And that codes doesn't make any building errors, and arduino blinks led well. (Last code, arduino blinks LED once, because the codes are in setup)
I miss 'pinMode(13, OUTPUT)' and even make codes in setup structure. But why that code's working?
Does setup structure is made for in purpose(initialize variables, pin modes, start using libraries)? Or just setup structure run once so people use this structure for specific purpose(initialize variables, pin modes, start using libraries)?
ps. sorry about my english skill ^^;;