초음파int distance;void setup() { pinMode(13,OUTPUT); pinMode(12,INPUT); pinMode(11,OUTPUT); Serial.begin(9600);}
void loop() { digitalWrite(13,1); delayMicroseconds(10); digitalWrite(13,0); distance = pulseIn(12,HIGH)/58.2; Serial.println(distance); if(distance <=10){ digitalWrite(11,1);} else { digitalWrite(11,0);}}