본문 바로가기
IOT

아두이노 - 신호등 만들기

by devdevdev 2022. 3. 28.
int REDpin = 6;
int YELLOWpin = 5;
int GREENpin = 4;

void setup() {
  pinMode(REDpin, OUTPUT);
  pinMode(YELLOWpin, OUTPUT);
  pinMode(GREENpin, OUTPUT);
}

void loop() {
  digitalWrite(REDpin, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(5000); // wait for a second
  digitalWrite(REDpin, LOW); // turn the LED off by making the voltage LOW
  digitalWrite(GREENpin, HIGH);    
  delay(5000);    
  digitalWrite(GREENpin, LOW);
  digitalWrite(YELLOWpin, HIGH);
  delay(1000);
  digitalWrite(YELLOWpin, LOW);
}
728x90

'IOT' 카테고리의 다른 글

인강 실습 포인트  (0) 2022.03.31
# GND  (0) 2022.03.31
# 풀다운과 풀업  (0) 2022.03.31
아두이노 - PWM 활용하기  (0) 2022.03.28

댓글