参考: ミニ・アダプタmyDAQとLabVIEWで作るMy実験ベンチ: パソコンに取り込んで計測・制御思いのままに (計測・制御シリーズ), p.43-44
- 下のように接続する。
- MAX を起動し、テストパネルを開いて、[デジタルI/O] タブを選択する。
- [すべて入力] ボタンをクリックする。
- [開始] ボタンをクリックする。
.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); } }