demo code for mbed iterface
Dependencies: RPCInterface mbed
Fork of RPC_RangeFinderDemo by
main.cpp
- Committer:
- MichaelW
- Date:
- 2010-09-20
- Revision:
- 0:5e8f67a3fc53
- Child:
- 1:e5e4988258b9
File content as of revision 0:5e8f67a3fc53:
#include "mbed.h" #include "SerialRPCInterface.h" #include "SRF08.h" using namespace mbed; //Create the interface on the USB Serial Port SerialRPCInterface RPC(USBTX, USBRX); void ReadRange(char * input, char * output); RPCFunction RangeFinder(&ReadRange, "RangeFinder"); SRF08 srf08(p9, p10, 0xE0); // Define SDA, SCL pin and I2C address DigitalOut myled(LED1); int main() { //The range finder demo also uses 2 servos but these will be handled entirly over the RPC while(1) { myled = 1; wait(0.2); myled = 0; wait(0.2); } } //As neither I2C nor the SRF08 library is avalible directly over RPC we create a Custom Function which we make RPCable by attaching to an RPCFunction void ReadRange(char * input, char * output){ //Format the output of the srf08 into the output string sprintf(output, "%f", srf08.read()); }