Page 173 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 173

PDA 07  5/27/03  8:44 AM  Page 149
                                      // Get the command sent from the PDA
                                      //  Chapter 7 / Programming the PIC16F876 Microcontroller
                                      cmd = fgetc(PDA);
                                      //
                                      //  Motor 1 commands
                                      //

                                      //
                                      // Motor 1 Forward
                                      //

                                      if( cmd == 'a')
                                      {
                                        output_high(PIN_B2);
                                        output_low(PIN_B3);
                                      }
                                      //
                                      // Motor 1 Reverse
                                      //
                                      if( cmd == 'b')
                                      {
                                        output_low(PIN_B2);
                                        output_high(PIN_B3);
                                      }
                                      //
                                      // Motor 1 Stop
                                      //
                                      if( cmd == 'c')
                                      {
                                        output_low(PIN_B2);
                                        output_low(PIN_B3);
                                      }

                                      //
                                      // Motor 2 Forward
                                      //

                                      if( cmd == 'd')
                                      {
                                        output_high(PIN_B4);
                                        output_low(PIN_B5);
                                      }

                                      //
                                      // Motor 2 Reverse
                                      //

                                                                                               149
   168   169   170   171   172   173   174   175   176   177   178