![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Code to control HC05 bluetooth bot
Dependencies: mbed 4DGL-uLCD-SE Motor RPCInterface
main.cpp@4:92435cf4d9f8, 2019-11-25 (annotated)
- Committer:
- kdickerson30
- Date:
- Mon Nov 25 16:49:27 2019 +0000
- Revision:
- 4:92435cf4d9f8
- Parent:
- 3:5d573864f5a2
Test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MichaelW | 1:e5e4988258b9 | 1 | /** |
MichaelW | 1:e5e4988258b9 | 2 | * Copyright (c)2010 ARM Ltd. |
MichaelW | 1:e5e4988258b9 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
MichaelW | 1:e5e4988258b9 | 4 | */ |
MichaelW | 0:5e8f67a3fc53 | 5 | #include "mbed.h" |
MichaelW | 0:5e8f67a3fc53 | 6 | #include "SerialRPCInterface.h" |
kdickerson30 | 4:92435cf4d9f8 | 7 | #include "uLCD_4DGL.h" |
kdickerson30 | 4:92435cf4d9f8 | 8 | #include "Motor.h" |
kdickerson30 | 4:92435cf4d9f8 | 9 | |
kdickerson30 | 4:92435cf4d9f8 | 10 | Motor mr(p23, p19, p20); // pwm, fwd, rev |
kdickerson30 | 4:92435cf4d9f8 | 11 | Motor ml(p24, p21, p22); // pwm, fwd, rev |
kdickerson30 | 4:92435cf4d9f8 | 12 | Serial pc(USBTX, USBRX); |
kdickerson30 | 4:92435cf4d9f8 | 13 | InterruptIn state(p11); |
kdickerson30 | 4:92435cf4d9f8 | 14 | float r; |
kdickerson30 | 4:92435cf4d9f8 | 15 | float l; |
kdickerson30 | 4:92435cf4d9f8 | 16 | RPCVariable<float> rpc_l(&l, "l"); |
kdickerson30 | 4:92435cf4d9f8 | 17 | RPCVariable<float> rpc_r(&r, "r"); |
MichaelW | 0:5e8f67a3fc53 | 18 | |
MichaelW | 0:5e8f67a3fc53 | 19 | using namespace mbed; |
MichaelW | 0:5e8f67a3fc53 | 20 | |
MichaelW | 0:5e8f67a3fc53 | 21 | //Create the interface on the USB Serial Port |
kdickerson30 | 4:92435cf4d9f8 | 22 | SerialRPCInterface RPC(p9, p10); |
kdickerson30 | 4:92435cf4d9f8 | 23 | |
kdickerson30 | 4:92435cf4d9f8 | 24 | void stop(){ |
kdickerson30 | 4:92435cf4d9f8 | 25 | r = 0; |
kdickerson30 | 4:92435cf4d9f8 | 26 | l = 0; |
kdickerson30 | 4:92435cf4d9f8 | 27 | } |
MichaelW | 0:5e8f67a3fc53 | 28 | |
MichaelW | 0:5e8f67a3fc53 | 29 | int main() { |
kdickerson30 | 4:92435cf4d9f8 | 30 | r = 0; |
kdickerson30 | 4:92435cf4d9f8 | 31 | l = 0; |
kdickerson30 | 4:92435cf4d9f8 | 32 | |
kdickerson30 | 4:92435cf4d9f8 | 33 | state.fall(&stop); |
kdickerson30 | 4:92435cf4d9f8 | 34 | |
MichaelW | 0:5e8f67a3fc53 | 35 | while(1) { |
kdickerson30 | 4:92435cf4d9f8 | 36 | mr.speed(r); |
kdickerson30 | 4:92435cf4d9f8 | 37 | ml.speed(l); |
kdickerson30 | 4:92435cf4d9f8 | 38 | pc.printf("Left:%f Right:%f\n\r", l, r); |
kennyainny | 3:5d573864f5a2 | 39 | |
MichaelW | 0:5e8f67a3fc53 | 40 | } |
MichaelW | 0:5e8f67a3fc53 | 41 | } |