Page 365 - MDP2022-2
P. 365

digitalWrite(right,  0);
                }
                if  (input1  ==  '1')  {
                    Serial.print("up\n");
                    u  =  !u;
                    d  =  0;
                    digitalWrite(down,  0);
                    digitalWrite(up,  u);
                }
                if  (input1  ==  '2')  {
                    Serial.print("down\n");
                    d  =  !d;
                    u  =  0;
                    digitalWrite(up,  0);
                    digitalWrite(down,  d);
                }


                if  (input1  ==  '3')  {
                    Serial.print("left\n");
                    l  =  !l;
                    r  =  0;
                    digitalWrite(right,  0);
                    digitalWrite(left,  l);
                }
                if  (input1  ==  '4')  {
                    Serial.print("right\n");
                    l  =  0;
                    r  =  !r;
                    digitalWrite(left,  0);
                    digitalWrite(right,  r);
                }


                if  (input1  ==  '5')  {
                    Serial.print("drop!\n");
                    digitalWrite(up,  0);
                    digitalWrite(down,  0);
                    digitalWrite(left,  0);
                    digitalWrite(right,  0);
                    digitalWrite(drop,  1);
                    delay(10);
                    digitalWrite(drop,  0);
                    delay(3800);  //내려가는  모터  돌아가는  시간


                    servo.write(180);  //  정회전
                    delay(2500);
   360   361   362   363   364   365   366   367   368   369   370