Matlab connection via the serial port, to control the robot from there (interactively)
example.cpp@3:4fd668c1dbf5, 2016-11-01 (annotated)
- Committer:
- jbrouwer
- Date:
- Tue Nov 01 02:36:29 2016 +0000
- Revision:
- 3:4fd668c1dbf5
Added example code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jbrouwer | 3:4fd668c1dbf5 | 1 | #include "mbed.h" |
jbrouwer | 3:4fd668c1dbf5 | 2 | #include "MatlabComm.h" |
jbrouwer | 3:4fd668c1dbf5 | 3 | |
jbrouwer | 3:4fd668c1dbf5 | 4 | MatlabComm MyComm(D4, D5, D12, D13); |
jbrouwer | 3:4fd668c1dbf5 | 5 | |
jbrouwer | 3:4fd668c1dbf5 | 6 | Ticker MyTest; |
jbrouwer | 3:4fd668c1dbf5 | 7 | |
jbrouwer | 3:4fd668c1dbf5 | 8 | double test_rate = 0.01; |
jbrouwer | 3:4fd668c1dbf5 | 9 | |
jbrouwer | 3:4fd668c1dbf5 | 10 | |
jbrouwer | 3:4fd668c1dbf5 | 11 | bool flag1 = false; |
jbrouwer | 3:4fd668c1dbf5 | 12 | void test(){ |
jbrouwer | 3:4fd668c1dbf5 | 13 | flag1=true; |
jbrouwer | 3:4fd668c1dbf5 | 14 | } |
jbrouwer | 3:4fd668c1dbf5 | 15 | |
jbrouwer | 3:4fd668c1dbf5 | 16 | int main() |
jbrouwer | 3:4fd668c1dbf5 | 17 | { |
jbrouwer | 3:4fd668c1dbf5 | 18 | MyTest.attach(&test, test_rate); |
jbrouwer | 3:4fd668c1dbf5 | 19 | while (true) { |
jbrouwer | 3:4fd668c1dbf5 | 20 | if (flag1){ |
jbrouwer | 3:4fd668c1dbf5 | 21 | flag1=false; |
jbrouwer | 3:4fd668c1dbf5 | 22 | MyComm.Step(); |
jbrouwer | 3:4fd668c1dbf5 | 23 | } |
jbrouwer | 3:4fd668c1dbf5 | 24 | } |
jbrouwer | 3:4fd668c1dbf5 | 25 | } |