728x90
조도센스 LED 릴레이 |
#define DELAY_TIME 100 #define DELAY_TIME2 500 int cdsPin=0; int cdsValue=0; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(2,OUTPUT); pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); } void loop() { // put your main code here, to run repeatedly: cdsValue=analogRead(cdsPin); Serial.println(analogRead(0)); if(cdsValue>10){ digitalWrite(2,HIGH); delay(DELAY_TIME); digitalWrite(2,LOW); digitalWrite(3,HIGH); delay(DELAY_TIME); digitalWrite(3,LOW); digitalWrite(4,HIGH); delay(DELAY_TIME); digitalWrite(4,LOW); digitalWrite(5,HIGH); delay(DELAY_TIME); digitalWrite(5,LOW); digitalWrite(6,HIGH); delay(DELAY_TIME); digitalWrite(6,LOW); digitalWrite(5,HIGH); delay(DELAY_TIME); digitalWrite(5,LOW); digitalWrite(4,HIGH); delay(DELAY_TIME); digitalWrite(4,LOW); digitalWrite(3,HIGH); delay(DELAY_TIME); digitalWrite(3,LOW); digitalWrite(2,HIGH); delay(DELAY_TIME2); digitalWrite(2,LOW); digitalWrite(3,HIGH); delay(DELAY_TIME2); digitalWrite(3,LOW); digitalWrite(4,HIGH); delay(DELAY_TIME2); digitalWrite(4,LOW); digitalWrite(5,HIGH); delay(DELAY_TIME2); digitalWrite(5,LOW); digitalWrite(6,HIGH); delay(DELAY_TIME2); digitalWrite(6,LOW); digitalWrite(5,HIGH); delay(DELAY_TIME2); digitalWrite(5,LOW); digitalWrite(4,HIGH); delay(DELAY_TIME2); digitalWrite(4,LOW); digitalWrite(3,HIGH); delay(DELAY_TIME2); digitalWrite(3,LOW); digitalWrite(2,HIGH); delay(DELAY_TIME); digitalWrite(2,LOW); digitalWrite(3,HIGH); delay(DELAY_TIME2); digitalWrite(3,LOW); digitalWrite(4,HIGH); delay(DELAY_TIME); digitalWrite(4,LOW); digitalWrite(5,HIGH); delay(DELAY_TIME2); digitalWrite(5,LOW); digitalWrite(6,HIGH); delay(DELAY_TIME); digitalWrite(6,LOW); digitalWrite(5,HIGH); delay(DELAY_TIME2); digitalWrite(5,LOW); digitalWrite(4,HIGH); delay(DELAY_TIME); digitalWrite(4,LOW); digitalWrite(3,HIGH); delay(DELAY_TIME2); digitalWrite(3,LOW); } } |
728x90
'■ Computer > ㅡArduino' 카테고리의 다른 글
아두이노 - blinkLED 함수 정의 (0) | 2020.03.26 |
---|---|
아두이노 - 가변저항,LED (0) | 2020.03.26 |
아두이노 - 문자 입력으로 LED 제어하기 (0) | 2020.03.25 |
아두이노 - 조도센스, 시리얼 모니터 표시 (0) | 2020.03.25 |
아두이노 - 삼색 LED 서서히 밝기 조절 (0) | 2020.03.24 |