Page 125 - MDP2020-1
P. 125

················································································  명장양성프로젝트  【MDP】  과제발표회  자료집  Ⅰ    |  119


                 delayMicroseconds(10);                        //  10us  딜레이

                 digitalWrite(trig,  LOW);                //  Trig  핀  Low
                 duration  =  pulseIn(echo,  HIGH);
                       Serial.println(duration);
                   if(duration<400){
                     servo1.write(0);

                     delay(3000);
                     servo1.write(90);
                   }
                   else{servo1.write(90);}
                       delay(100);

                 delay(100);
                 //  Reset  the  loop  if  no  new  card  present  on  the  sensor/reader.  This  saves  the
             entire  process  when  idle.
                 if  (  !  rfid.PICC_IsNewCardPresent())
                     return;

                 //  Verify  if  the  NUID  has  been  readed
                 if  (  !  rfid.PICC_ReadCardSerial())
                     return;
                 Serial.print("UID  tag  :");
                 String  content=  "";

                 byte  letter;
                 for  (byte  i  =  0;  i  <  rfid.uid.size;  i++)
                 {
                       Serial.print(rfid.uid.uidByte[i]  <  0x10  ?  "  0"  :  "  ");
                       Serial.print(rfid.uid.uidByte[i],  HEX);

                       content.concat(String(rfid.uid.uidByte[i]  <  0x10  ?  "  0"  :  "  "));
                       content.concat(String(rfid.uid.uidByte[i],  HEX));
                 }
                 Serial.println();
                 Serial.print("Message  :  ");
                 content.toUpperCase();

                 //  UID값이  아래  값과  같으면  승인  처리
                 if  (content.substring(1)  ==  "BB  D1  53  4B")  //  승인  하고자하는  UID  기록
                 {
                   //  인증이  되면  Green  LED와  함께  서보모터를  작동시킨다.

                     Serial.println("Authorized  access");
                     Serial.println();
                     digitalWrite(GLED,HIGH);
                     //servo.write(180);      //  서보모터의  각도를  변경한다
   120   121   122   123   124   125   126   127   128   129   130