Arduino 4 プログラミング

みんなのArduino入門

みんなのArduino入門

プリプロセッサ
  • #include <ヘッダーファイル名>
  • #define 文字列 置換する式、数字、文字列
  • ##
  • #条件付きコンパイル
  • #import
const と static
  • 定数化 const int led = 13;
  • 初期化 static int i = 0;
変数の範囲とメモリーサイズ
  • int: -32768 から +32767
  • unsigned int: 0 から 65536
  • sizeof
配列
  • int x[] = {2, 4, 5, 6, 9};
  • char ch[] = {'a', 'x', 'y', 'c'};
構造体
  • struct date {int year; byte month; byte day; char wday[4]};
文字・文字列関数
文字関数 説明
stract 文字列の連結
strchr, strstr 文字列の文字検索、文字列の文字列検索
strcmp, strncmp 文字列の比較
strcpy 文字列の複写
strlen 文字列の長さ
時間制御関数
時間制御関数 説明
millis() Arduinoが起動してからの時間(ミリ秒)を返す
micros() Arduinoが起動してからの時間(マイクロ秒)を返す
delay(ms) 待機時間(ミリ秒)msを設定
delayMicroseconds(us) 待機時間(マイクロ秒)usを設定