Loop()

From Microduino Wiki
Jump to: navigation, search
  • loop()

Setup() function has been used to initialize and define the variables, then call loop() function.

Loop function loops consecutively in the process of the program running, and changes the implementation according to feedback.

Control Arduino main control board through this function.

  • Example

int buttonPin = 3;
 
// initialize serial and buttonpin in setup. 
void setup()
{
  beginSerial(9600);
  pinMode(buttonPin, INPUT);
}
 
//check button each time, it the button is pressed, send the information to the serial in loop. 
 
void loop()
{
  if (digitalRead(buttonPin) == HIGH)
    serialWrite('H');
  else
    serialWrite('L');
 
  delay(1000);
}

[Return to Arduino Syntax Manual]