손씻기 알람 메이커 키트
페이지 정보
관련링크
본문
↓ [코딩 소스] ↓
void setup()
{
pinMode(11,OUTPUT); //RED
pinMode(10,OUTPUT); //GREEN
pinMode(9,OUTPUT); //BLUE
pinMode(7,INPUT); //IR sensor
pinMode(3, OUTPUT); //buzzer
}
void loop()
{
int infrared= digitalRead(7);
delay(500);
digitalWrite(11,HIGH); //RED on
digitalWrite(10,LOW); //GREEN off
digitalWrite(9,LOW); //BLUE off
if(infrared==0)
{
digitalWrite(11,LOW); //red on, off
delay(500);
digitalWrite(11,HIGH);
delay(500);
digitalWrite(11,LOW);
for(int i=0; i<30; i++)
{
digitalWrite(9,HIGH);//blue 30 second on
delay(1000);
}
digitalWrite(9,LOW);
digitalWrite(10,HIGH); // green on
delay(500);
digitalWrite(10,LOW);
delay(500);
tone(3, 2551,200);
delay(300);
tone(3, 2551,200);
delay(300);
tone(3, 3034,200);
delay(300);
tone(3, 3405,200);
delay(300);
tone(3, 2551,200);
delay(300);
noTone(3);
}
}
댓글목록
등록된 댓글이 없습니다.