2019/12/08

セレクタ act.4

Arduinoのプログラムをスケッチ
16個を順番に点灯させてみました。


-----------------------------------------------------------------
//daikunomokichi 2019-12-08
const int d_pin0 = 0;           // LED connected to digital pin 0
const int d_pin1 = 1;           // LED connected to digital pin 1
const int d_pin2 = 2;           // LED connected to digital pin 2
const int d_pin3 = 3;           // LED connected to digital pin 3
const int d_pin4 = 4;           // LED connected to digital pin 4
const int d_pin5 = 5;           // LED connected to digital pin 5
const int d_pin6 = 6;           // LED connected to digital pin 6
const int d_pin7 = 7;           // LED connected to digital pin 7
const int d_pin8 = 8;           // LED connected to digital pin 8
const int d_pin9 = 9;           // LED connected to digital pin 9
const int d_pin10 = 10;           // LED connected to digital pin 10
const int d_pin11 = 11;           // LED connected to digital pin 11
const int d_pin12 = 12;           // LED connected to digital pin 12
const int d_pin13 = 13;           // LED connected to digital pin 13
const int d_pin14 = 14;           // LED connected to digital pin 14 A0
const int d_pin15 = 15;           // LED connected to digital pin 15 A1
const int d_pin16 = 16;           // LED connected to digital pin 16 A2

void setup() {
  pinMode( d_pin0, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin1, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin2, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin3, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin4, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin5, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin6, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin7, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin8, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin9, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin10, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin11, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin12, OUTPUT );     // sets the digital pin as output
  pinMode( d_pin14, OUTPUT );     // sets the digital pin as output A0
  pinMode( d_pin15, OUTPUT );     // sets the digital pin as output A1
  pinMode( d_pin16, OUTPUT );     // sets the digital pin as output A2
  pinMode( d_pin13, INPUT );      // sets the digital pin as input
  digitalWrite(d_pin13, HIGH);

  delay( 2000 );
  digitalWrite( d_pin0, HIGH );  // sets the LED off
  digitalWrite( d_pin1, HIGH );  // sets the LED off
  digitalWrite( d_pin2, HIGH );  // sets the LED off
  digitalWrite( d_pin3, HIGH );  // sets the LED off
  digitalWrite( d_pin4, HIGH );  // sets the LED off
  digitalWrite( d_pin5, HIGH );  // sets the LED off
  digitalWrite( d_pin6, HIGH );  // sets the LED off
  digitalWrite( d_pin7, HIGH );  // sets the LED off
  digitalWrite( d_pin8, HIGH );  // sets the LED off
  digitalWrite( d_pin9, HIGH );  // sets the LED off
  digitalWrite( d_pin10, HIGH );  // sets the LED off
  digitalWrite( d_pin11, HIGH );  // sets the LED off
  digitalWrite( d_pin12, HIGH );  // sets the LED off
  digitalWrite( d_pin14, HIGH );  // sets the LED off
  digitalWrite( d_pin15, HIGH );  // sets the LED off
  digitalWrite( d_pin16, HIGH );  // sets the LED off
  delay( 1000 );
}

void loop() {
  digitalWrite( d_pin0, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin0, HIGH );  // sets the LED off
  digitalWrite( d_pin1, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin1, HIGH );  // sets the LED off
  digitalWrite( d_pin2, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin2, HIGH );  // sets the LED off
  digitalWrite( d_pin3, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin3, HIGH );  // sets the LED off
  digitalWrite( d_pin4, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin4, HIGH );  // sets the LED off
  digitalWrite( d_pin5, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin5, HIGH );  // sets the LED off
  digitalWrite( d_pin6, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin6, HIGH );  // sets the LED off
  digitalWrite( d_pin7, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin7, HIGH );  // sets the LED off
  digitalWrite( d_pin8, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin8, HIGH );  // sets the LED off
  digitalWrite( d_pin9, LOW );   // sets the LED on
  delay( 1000 );                 // waits for a second
  digitalWrite( d_pin9, HIGH );  // sets the LED off
  digitalWrite( d_pin10, LOW );   // sets the LED on
  delay( 1000 );                  // waits for a second
  digitalWrite( d_pin10, HIGH );  // sets the LED off
  digitalWrite( d_pin11, LOW );   // sets the LED on
  delay( 1000 );                  // waits for a second
  digitalWrite( d_pin11, HIGH );  // sets the LED off
  digitalWrite( d_pin12, LOW );   // sets the LED on
  delay( 1000 );                  // waits for a second
  digitalWrite( d_pin12, HIGH );  // sets the LED off
  digitalWrite( d_pin14, LOW );   // sets the LED on
  delay( 1000 );                  // waits for a second
  digitalWrite( d_pin14, HIGH );  // sets the LED off
  digitalWrite( d_pin15, LOW );   // sets the LED on
  delay( 1000 );                  // waits for a second
  digitalWrite( d_pin15, HIGH );  // sets the LED off
  digitalWrite( d_pin16, LOW );   // sets the LED on
  delay( 1000 );                  // waits for a second
  digitalWrite( d_pin16, HIGH );  // sets the LED off
}

-----------------------------------------------------------------

0 件のコメント:

コメントを投稿