Code to control HC05 bluetooth bot
Dependencies: mbed 4DGL-uLCD-SE Motor RPCInterface
Diff: main.cpp
- Revision:
- 0:5e8f67a3fc53
- Child:
- 1:e5e4988258b9
diff -r 000000000000 -r 5e8f67a3fc53 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Sep 20 14:39:23 2010 +0000 @@ -0,0 +1,29 @@ +#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()); +}