728x90
반응형
const int LED = 13;

void setup()
{
  pinMode(LED, OUTPUT);
}

void loop()
{
 /*
 for(int t_high = 0; t_high<=10; t_high++)
 {
   digitalWrite(LED, HIGH);
   delay(t_high);
   
   digitalWrite(LED, LOW);
   delay(10-t_high);
 }
  */
 
  int t_high = 0;
  
  while (t_high <= 10)
  {
   digitalWrite(LED, HIGH);
   delay(t_high);
   
   digitalWrite(LED, LOW);
   delay(10-t_high);
     
   t_high++;
  }
}
const unsigned int led[8] = {2, 3, 4, 5, 6, 7, 8, 9};

void setup()
{
 for(int x = 0; x <= 7; x++)
 {
   pinMode(led[x], OUTPUT);
 }
}

void loop()
{
  //반복문에서 한번 반복할때마다 모든 LED를 끄고,
  //해당 순서의 LED만 켜둠
  
  for (int x = 0; x < 8; x++)
  {
   for (int i = 0; i < 8; i++)
   {
    digitalWrite(led[i], 0); //0 = LOW
   }
    digitalWrite(led[x], 1); //1 = HIGH
    
    delay(500);
  }
  
  
}
728x90
반응형

'Firmware & Embedded > AVR' 카테고리의 다른 글

10 Ways to Destroy An Arduino  (0) 2022.11.16
Serial Communication  (0) 2022.11.03
attachInterrupt  (0) 2022.09.22
PWM - Timer Library  (0) 2022.09.22
Analogue Read  (0) 2022.09.21

+ Recent posts