Example of usage of encoder library
Dependencies: Encoder MODSERIAL mbed
main.cpp@0:836046040450, 2013-09-26 (annotated)
- Committer:
- vsluiter
- Date:
- Thu Sep 26 14:12:19 2013 +0000
- Revision:
- 0:836046040450
- Child:
- 1:8d99355e740b
Simple example of usage of Encoder library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vsluiter | 0:836046040450 | 1 | #include "mbed.h" |
vsluiter | 0:836046040450 | 2 | #include "encoder.h" |
vsluiter | 0:836046040450 | 3 | #include "MODSERIAL.h" |
vsluiter | 0:836046040450 | 4 | |
vsluiter | 0:836046040450 | 5 | |
vsluiter | 0:836046040450 | 6 | int main() { |
vsluiter | 0:836046040450 | 7 | Encoder motor1(PTD0,PTC9); |
vsluiter | 0:836046040450 | 8 | MODSERIAL pc(USBTX,USBRX); |
vsluiter | 0:836046040450 | 9 | pc.baud(115200); |
vsluiter | 0:836046040450 | 10 | while(1) { |
vsluiter | 0:836046040450 | 11 | wait(0.2); |
vsluiter | 0:836046040450 | 12 | pc.printf("pos: %d, speed %f \r\n",motor1.getPosition(), motor1.getSpeed()); |
vsluiter | 0:836046040450 | 13 | } |
vsluiter | 0:836046040450 | 14 | } |