Programmaatje om de motoren aan te sturen met PuTTY.
Dependencies: Encoder MODSERIAL mbed
main.cpp@0:bd2d5dd6d9ff, 2014-10-22 (annotated)
- Committer:
- BasvanBuuren
- Date:
- Wed Oct 22 10:49:40 2014 +0000
- Revision:
- 0:bd2d5dd6d9ff
Simpel programmaatje om de motoren aan te sturen met PuTTY.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
BasvanBuuren | 0:bd2d5dd6d9ff | 1 | #include "mbed.h" |
BasvanBuuren | 0:bd2d5dd6d9ff | 2 | #include "encoder.h" |
BasvanBuuren | 0:bd2d5dd6d9ff | 3 | #include <iostream> |
BasvanBuuren | 0:bd2d5dd6d9ff | 4 | |
BasvanBuuren | 0:bd2d5dd6d9ff | 5 | int main() |
BasvanBuuren | 0:bd2d5dd6d9ff | 6 | { |
BasvanBuuren | 0:bd2d5dd6d9ff | 7 | PwmOut m_speed1(PTA5); |
BasvanBuuren | 0:bd2d5dd6d9ff | 8 | DigitalOut m_dir1(PTA4); |
BasvanBuuren | 0:bd2d5dd6d9ff | 9 | PwmOut m_speed2(PTC8); |
BasvanBuuren | 0:bd2d5dd6d9ff | 10 | DigitalOut m_dir2(PTC9); |
BasvanBuuren | 0:bd2d5dd6d9ff | 11 | |
BasvanBuuren | 0:bd2d5dd6d9ff | 12 | float s_speed1; |
BasvanBuuren | 0:bd2d5dd6d9ff | 13 | float s_dir1; |
BasvanBuuren | 0:bd2d5dd6d9ff | 14 | float s_speed2; |
BasvanBuuren | 0:bd2d5dd6d9ff | 15 | float s_dir2; |
BasvanBuuren | 0:bd2d5dd6d9ff | 16 | |
BasvanBuuren | 0:bd2d5dd6d9ff | 17 | |
BasvanBuuren | 0:bd2d5dd6d9ff | 18 | while(1) |
BasvanBuuren | 0:bd2d5dd6d9ff | 19 | { |
BasvanBuuren | 0:bd2d5dd6d9ff | 20 | cout << "Speed motor 1: " << endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 21 | cin >> s_speed1; |
BasvanBuuren | 0:bd2d5dd6d9ff | 22 | cout << s_speed1 << endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 23 | cout << "Direction motor 1: " << endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 24 | cin >> s_dir1; |
BasvanBuuren | 0:bd2d5dd6d9ff | 25 | cout << s_dir1 << endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 26 | cout << "Speed motor 2: " << endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 27 | cin >> s_speed2; |
BasvanBuuren | 0:bd2d5dd6d9ff | 28 | cout << s_speed2 << endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 29 | cout << "Direction motor 2: " << endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 30 | cin >> s_dir2; |
BasvanBuuren | 0:bd2d5dd6d9ff | 31 | cout << s_dir2 << endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 32 | m_speed1=0; |
BasvanBuuren | 0:bd2d5dd6d9ff | 33 | m_speed2=0; |
BasvanBuuren | 0:bd2d5dd6d9ff | 34 | cout << "Wait for it..." <<endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 35 | wait(3); |
BasvanBuuren | 0:bd2d5dd6d9ff | 36 | m_speed1=s_speed1; |
BasvanBuuren | 0:bd2d5dd6d9ff | 37 | m_dir1=s_dir1; |
BasvanBuuren | 0:bd2d5dd6d9ff | 38 | m_speed2=s_speed2; |
BasvanBuuren | 0:bd2d5dd6d9ff | 39 | m_dir2=s_dir2; |
BasvanBuuren | 0:bd2d5dd6d9ff | 40 | cout << "Go!" << endl; |
BasvanBuuren | 0:bd2d5dd6d9ff | 41 | wait(3); |
BasvanBuuren | 0:bd2d5dd6d9ff | 42 | } |
BasvanBuuren | 0:bd2d5dd6d9ff | 43 | } |