Программирование - это просто
Advertisement
arrow arrow . arrow . 3. " ".
01.02.2023 .
1:
C#
Delphi
Web-
Excel-
.
. 3. " ". E-mail
megabax   
15.11.2020 .
New Page 1

. 3. " ".

" " " ". , C, :

struct item {

    bool light; //

    int led; //

} a[16] = {{true, 10}, {true, 11}, {true, 12}, {true,13}, {false,13}, {false,12}, {false,11}, {false, 10}, {true, 10}, {false, 10}, {true,11},

          {false,11}, {true,12}, {false,12}, {true,13}, {false,13}}; 

 

 

void setup() {

  // put your setup code here, to run once:

  pinMode(10, OUTPUT);

  pinMode(11, OUTPUT);

  pinMode(12, OUTPUT);

  pinMode(13, OUTPUT);

}

 

void loop() {

  for(int i=0; i<16; i++)

  {

    if(a[i].light)

    {

      digitalWrite(a[i].led, HIGH); // ; led - , - (HIGH) (LOW)

    }

    else

    {

       digitalWrite(a[i].led, LOW); // ; led - , - (HIGH) (LOW)

    }

    delay(300); // , -

  }

}

 

 

(light=true) (light=false) . , ., , . ,   .

. , , , , . define count. -, :

 

#define count 16 // ,

 

struct node {

    bool light; //

    int led; //

    int delay_mils; //,

} a[count] = {{true, 10, 300}, {true, 11, 300}, {true, 12, 300}, {true,13, 300}, {false,13,1000}, {false,12,1000}, {false,11,1000}, {false, 10,1000}, {true, 10,500},

          {false, 10,200}, {true,11,500},

          {false,11,200}, {true,12,500}, {false,12,200}, {true,13,500}, {false,13,1500}}; 

 

 

void setup() {

  // put your setup code here, to run once:

  pinMode(10, OUTPUT);

  pinMode(11, OUTPUT);

  pinMode(12, OUTPUT);

  pinMode(13, OUTPUT);

}

 

void loop() {

  for(int i=0; i<count; i++)

  {

    if(a[i].light)

    {

      digitalWrite(a[i].led, HIGH); // ; led - , - (HIGH) (LOW)

    }

    else

    {

       digitalWrite(a[i].led, LOW); // ; led - , - (HIGH) (LOW)

    }

    delay(a[i].delay_mils); // , -

  }

}

 
« .   . »
 
© 2023 Программирование - это просто
Joomla! - , GNU/GPL.
© 2005-2008 Joom.Ru - Joomla!
Design by Mamboteam.com | Powered by Mambobanner.de
  .