0. setup() 与 loop() 函数

  • void setup():
    • // put your setup code here, to run once:
    • 仅执行一次;
  • void loop():
    • // put your main code here, to run repeatedly
    • 会重复执行多次;
  • setup:

    pinMode(LED_BUILTIN, OUTPUT);
            // pinMode 设置引脚模式
            // LED_BUILTIN:arduino 开发板上自带的 LED,将其指定为输出;
  • loop:

    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(3000);                       // 暂停三秒,也即 LED_BUILTIN 高电平持续三秒,也即亮三秒;
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    delay(1000);

2. 常用函数

  • millis() ⇒ 获取当前时间

    unsigned long currentMillis = millis();
posted on 2018-02-23 20:33  未雨愁眸  阅读(357)  评论(0编辑  收藏  举报