---
# System prepended metadata

title: light

---

light
===
```code=
int led_red = 0; // the red LED is connected to Pin 0 of the Arduino
int led_yellow = 1; // the yellow LED is connected to Pin 1 of the Arduino
int led_green = 2; // the green LED is connected to Pin 2 of the Arduino
int red2 = 3;
int yellow2 = 4;
int green2 = 5;


void setup() {
  // set up all the LEDs as OUTPUT
  pinMode(led_red, OUTPUT);
  pinMode(led_yellow, OUTPUT);
  pinMode(led_green, OUTPUT);
  pinMode(red2, OUTPUT);
  pinMode(yellow2, OUTPUT);
  pinMode(green2, OUTPUT);
  pinMode(6, OUTPUT);  
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  digitalWrite(13, 0);  // 關閉小數點

}
void number(int x)
{
  switch(x)
  {
    case 9:
    digitalWrite(6, 1);
    digitalWrite(7, 1);
    digitalWrite(8, 1);
    digitalWrite(9, 0);
    digitalWrite(10, 0);
    digitalWrite(11, 1);
    digitalWrite(12, 1);
    break;
  case 8:
  
    digitalWrite(6, 1);
    digitalWrite(7, 1);
    digitalWrite(8, 1);
    digitalWrite(9, 1);
    digitalWrite(10, 1);
    digitalWrite(11, 1);
    digitalWrite(12, 1);
    break;
  case 7:
    digitalWrite(6, 1);
    digitalWrite(7, 1);
    digitalWrite(8, 1);
    digitalWrite(9, 0);
    digitalWrite(10, 0);
    digitalWrite(11, 0);
    digitalWrite(12, 0);
    break;
  case 6:
    digitalWrite(6, 1);
    digitalWrite(7, 0);
    digitalWrite(8, 1);
    digitalWrite(9, 1);
    digitalWrite(10, 1);
    digitalWrite(11, 1);
    digitalWrite(12, 1);
    break;
  case 5:
    digitalWrite(6, 1);
    digitalWrite(7, 0);
    digitalWrite(8, 1);
    digitalWrite(9, 1);
    digitalWrite(10, 0);
    digitalWrite(11, 1);
    digitalWrite(12, 1);
    break;
  case 4:
    digitalWrite(6, 0);
    digitalWrite(7, 1);
    digitalWrite(8, 1);
    digitalWrite(9, 0);
    digitalWrite(10, 0);
    digitalWrite(11, 1);
    digitalWrite(12, 1);
    break;
  case 3:
    digitalWrite(6, 1);
    digitalWrite(7, 1);
    digitalWrite(8, 1);
    digitalWrite(9, 1);
    digitalWrite(10, 0);
    digitalWrite(11, 0);
    digitalWrite(12, 1);
    break;
  case 2:
    digitalWrite(6, 1);
    digitalWrite(7, 1);
    digitalWrite(8, 0);
    digitalWrite(9, 1);
    digitalWrite(10, 1);
    digitalWrite(11, 0);
    digitalWrite(12, 1);
    break;
  case 1:
    digitalWrite(6, 0);
    digitalWrite(7, 1);
    digitalWrite(8, 1);
    digitalWrite(9, 0);
    digitalWrite(10, 0);
    digitalWrite(11, 0);
    digitalWrite(12, 0);
    break;
  case 0:
    digitalWrite(6, 1);
    digitalWrite(7, 1);
    digitalWrite(8, 1);
    digitalWrite(9, 1);
    digitalWrite(10, 1);
    digitalWrite(11, 1);
    digitalWrite(12, 0);  
  }
}
int global;
void loop() {

  digitalWrite(led_red, LOW); 
  digitalWrite(led_yellow, LOW);
  digitalWrite(led_green, HIGH);
  digitalWrite(red2, HIGH); 
  digitalWrite(yellow2, LOW);
  digitalWrite(green2, LOW);
  for(int i=8;i>=0; i--)
  {
    delay(1000);
    number(i);
    
  }
  
  digitalWrite(led_red, LOW);   
  digitalWrite(led_yellow, HIGH);
  digitalWrite(led_green, LOW);
  delay(1000); 
  
  digitalWrite(led_red, HIGH);  
  digitalWrite(led_yellow, LOW);
  digitalWrite(led_green, LOW);
  
  digitalWrite(red2, LOW); 
  digitalWrite(yellow2, LOW);
  digitalWrite(green2, HIGH);
  for(int i=5;i>=0; i--)
  {
    delay(1000);
    number(i);
    
  }
  
  digitalWrite(red2, LOW); 
  digitalWrite(yellow2, HIGH);
  digitalWrite(green2, LOW);
  delay(1000);
  
}
```