Arduino 記事本 01 : 程式的基本格式

網頁筆記本-001

  •  Arduino !!!

  • 程式的基本格式
// 引用
#include "ESP8266WiFi.h"
// 設定全域變數
char cData[20];

// 替腳位安上易分辨的名稱
int Pin_In_Contact  = 12;
int Pin_Out_Contact = 5;

// 初始化區 - 只執行一次
void setup() {
    // 設定腳位功能
    pinMode(Pin_In_Contact, INPUT);
    pinMode(Pin_Out_Contact, OUTPUT);

    // 預設狀態
    digitalWrite(Pin_Out_Contact, HIGH);
}

// 自訂Function
bool Reset() {
    digitalWrite(Pin_Out_Contact, HIGH);
}

// 程式區 , 無限循環執行
void loop() {

    // 暫停0.5秒
    delay(500);
}

留言

這個網誌中的熱門文章

Arduino 記事本 07 : 發出聲音(無源蜂鳴器)控制

Arduino 記事本 06 : Read-Time Clock(RTC)模組

Arduino 記事本 04 : 使用內建提升電阻