LabVIEW & myDAQ 7 / MAX のテストパネルで動作確認をする 5 / ディジタル入力 (DI) を使う

参考: ミニ・アダプタmyDAQとLabVIEWで作るMy実験ベンチ: パソコンに取り込んで計測・制御思いのままに (計測・制御シリーズ), p.43-44

  1. 下のように接続する。
    f:id:ti-nspire:20170821145059p:plain:h220 f:id:ti-nspire:20170821145112j:plain:h220
  2. MAX を起動し、テストパネルを開いて、[デジタルI/O] タブを選択する。
  3. [すべて入力] ボタンをクリックする。
  4. [開始] ボタンをクリックする。


.ino (参考: Arduino - KnightRider。★の箇所を変えた)

/* Knight Rider 2
 * --------------
 *
 * Reducing the amount of code using for(;;).
 *
 *
 * (cleft) 2005 K3, Malmo University
 * @author: David Cuartielles
 * @hardware: David Cuartielles, Aaron Hallborg
 */

//int pinArray[] = {2, 3, 4, 5, 6, 7}; // ★
int pinArray[] = {2, 3, 4, 5, 6, 7, 8, 9}; // ★
int count = 0;
//int timer = 100; // ★
int timer = 200; // ★

void setup(){
  // we make all the declarations at once
  //for (count=0;count<6;count++) { // ★
  for (count=0;count<8;count++) { // ★
    pinMode(pinArray[count], OUTPUT);
  }
}

void loop() {
  //for (count=0;count<6;count++) { // ★
  for (count=0;count<8;count++) { // ★
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer);
  }
  //for (count=5;count>=0;count--) { // ★
  for (count=7;count>=0;count--) { // ★
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer);
  }
}