four led

arduino_2017. 10. 10. 17:16



const int RedPin    = 13;

const int BluePin   = 12;

const int YellowPin = 11;

const int GreenPin  = 10;

void setup() {

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

  pinMode(RedPin, OUTPUT);

  pinMode(BluePin, OUTPUT);

  pinMode(YellowPin, OUTPUT);

  pinMode(GreenPin, OUTPUT);

  Serial.begin(9600);

}


void loop() {

  // put your main code here, to run repeatedly:

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

  {

    if (i%2 == 0)

    {

      digitalWrite(11, LOW); // YellowPin

      digitalWrite(13, LOW); // RedPin

      digitalWrite(10, HIGH); // GreenPin

      digitalWrite(12, HIGH); // BluePin

      delay(1000); // 1 seconds 

    }

    else

    {

      digitalWrite(10, LOW); // YellowPin

      digitalWrite(12, LOW); // RedPin

      digitalWrite(11, HIGH); // GreenPin

      digitalWrite(13, HIGH); // BluePin

      delay(1000); // 1 seconds 

    }

  }

}

'arduino_' 카테고리의 다른 글

four led ver2  (0) 2017.10.10
LED _VER2 FOUR  (0) 2017.10.10
sds011 - 먼지 센서  (0) 2017.09.21
데이터 사이즈  (0) 2017.09.21
10개만 출력  (0) 2016.03.26