Page 174 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 174
PDA 07 5/27/03 8:44 AM Page 150
if( cmd == 'e') PDA Robotics
{
output_low(PIN_B4);
output_high(PIN_B5);
}
//
// Motor 2 Stop
//
if( cmd == 'f')
{
output_low(PIN_B4);
output_low(PIN_B5);
}
//
// The PDA has requested that we get the value from the
// Analog input of the Range Finder
//
if( cmd == 'g')
{
//
// Give some time for the clear to send. We could check the CLS
// pin from the MCP2150 here by reading the port value of Pins
// RB6 and RB7 can be configured as.inputs and used to monitor the
// MCP2150's Request to send (RTS: pin 13) and Clear to send (CTS: pin 12)
// because I have connected them on the circuit board. However, if the data is
// lost the PDA will ask for it again. See Chapter 5, Figure 5.12: Schematic of
// PIC16F876 connection to MCP2150
//
delay_ms(3);
//
// Read the analog value from the range finder
//
range_value = Read_ADC();
//
// Send the value to the PDA
//
putc(range_value);
}
}
}
150