Loop()

From Microduino Wiki
Revision as of 03:57, 4 August 2016 by Fengfeng (talk) (Created page with "*'''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 progra...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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]