![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Geschwindigkeitesregelung durch den Ultraschallsensor
Dependencies: BertlLib bertl_libraries mbed
main.cpp@0:9ff985002d48, 2016-04-25 (annotated)
- Committer:
- TFuchsbichler
- Date:
- Mon Apr 25 06:58:09 2016 +0000
- Revision:
- 0:9ff985002d48
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TFuchsbichler | 0:9ff985002d48 | 1 | #include "mbed.h" |
TFuchsbichler | 0:9ff985002d48 | 2 | #include "Bertl14.h" |
TFuchsbichler | 0:9ff985002d48 | 3 | #include "BertlObjects.h" |
TFuchsbichler | 0:9ff985002d48 | 4 | #include "class_hardware.h" |
TFuchsbichler | 0:9ff985002d48 | 5 | #include "pins_bertl.h" |
TFuchsbichler | 0:9ff985002d48 | 6 | |
TFuchsbichler | 0:9ff985002d48 | 7 | |
TFuchsbichler | 0:9ff985002d48 | 8 | BusOut boardPow(PW_MOT, PW_IR, PW_ENC); |
TFuchsbichler | 0:9ff985002d48 | 9 | |
TFuchsbichler | 0:9ff985002d48 | 10 | Motor m_right(MR_PWM, MR_FWD, MR_REV); |
TFuchsbichler | 0:9ff985002d48 | 11 | Motor m_left(ML_PWM, ML_FWD, ML_REV); |
TFuchsbichler | 0:9ff985002d48 | 12 | |
TFuchsbichler | 0:9ff985002d48 | 13 | USSensor usens(US_T,US_E); |
TFuchsbichler | 0:9ff985002d48 | 14 | |
TFuchsbichler | 0:9ff985002d48 | 15 | int main() { |
TFuchsbichler | 0:9ff985002d48 | 16 | boardPow=3; |
TFuchsbichler | 0:9ff985002d48 | 17 | InitBertl(); |
TFuchsbichler | 0:9ff985002d48 | 18 | pex.useISR=0; leds=9; |
TFuchsbichler | 0:9ff985002d48 | 19 | pex.ClearLeds(); |
TFuchsbichler | 0:9ff985002d48 | 20 | pex.WaitUntilButtonPressed(); |
TFuchsbichler | 0:9ff985002d48 | 21 | pex.WaitUntilButtonPressed(); |
TFuchsbichler | 0:9ff985002d48 | 22 | usens.initialize(); |
TFuchsbichler | 0:9ff985002d48 | 23 | while(1) { |
TFuchsbichler | 0:9ff985002d48 | 24 | |
TFuchsbichler | 0:9ff985002d48 | 25 | int speed = ( usens.distance_mm - 80 ) * 1; |
TFuchsbichler | 0:9ff985002d48 | 26 | |
TFuchsbichler | 0:9ff985002d48 | 27 | m_left.set(speed); |
TFuchsbichler | 0:9ff985002d48 | 28 | m_right.set(speed); |
TFuchsbichler | 0:9ff985002d48 | 29 | |
TFuchsbichler | 0:9ff985002d48 | 30 | } |
TFuchsbichler | 0:9ff985002d48 | 31 | } |