![](/media/cache/group/11700697_10200701668420946_8214886085951071495_o.jpg.50x50_q85.jpg)
mobile robot control with artificial hormones
Dependencies: Communication_Robot RTC-DS1307 iSerial mbed
Fork of Andante_v00 by
main.cpp@0:95d17607a698, 2015-02-28 (annotated)
- Committer:
- soulx
- Date:
- Sat Feb 28 16:25:25 2015 +0000
- Revision:
- 0:95d17607a698
- Child:
- 2:b31c4677ebc0
mobile robot control with artificial hormones; -first create pin and structure main code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
soulx | 0:95d17607a698 | 1 | #include "mbed.h" |
soulx | 0:95d17607a698 | 2 | #include "param.h" |
soulx | 0:95d17607a698 | 3 | #include "pin_config.h" |
soulx | 0:95d17607a698 | 4 | |
soulx | 0:95d17607a698 | 5 | //control stearing |
soulx | 0:95d17607a698 | 6 | PwmOut heading_front(PIN_FRONT_SERVO); |
soulx | 0:95d17607a698 | 7 | PwmOut heading_rear(PIN_REAR_SERVO); |
soulx | 0:95d17607a698 | 8 | //control speed |
soulx | 0:95d17607a698 | 9 | PwmOut drive_motor(PIN_RC_SPEED); |
soulx | 0:95d17607a698 | 10 | |
soulx | 0:95d17607a698 | 11 | //led debugging |
soulx | 0:95d17607a698 | 12 | DigitalOut myled(LED1); |
soulx | 0:95d17607a698 | 13 | |
soulx | 0:95d17607a698 | 14 | //set foreground |
soulx | 0:95d17607a698 | 15 | Ticker Update_command; |
soulx | 0:95d17607a698 | 16 | Ticker Samping; |
soulx | 0:95d17607a698 | 17 | |
soulx | 0:95d17607a698 | 18 | void Init_servo() |
soulx | 0:95d17607a698 | 19 | { |
soulx | 0:95d17607a698 | 20 | heading_front.period_ms(20); |
soulx | 0:95d17607a698 | 21 | heading_rear.period_ms(20); |
soulx | 0:95d17607a698 | 22 | drive_motor.period_ms(20); |
soulx | 0:95d17607a698 | 23 | } |
soulx | 0:95d17607a698 | 24 | void Init_communication() |
soulx | 0:95d17607a698 | 25 | { |
soulx | 0:95d17607a698 | 26 | iSerial pan_a(TX_PAN_A, RX_PAN_A); // tx, rx |
soulx | 0:95d17607a698 | 27 | iSerial pan_b(TX_PAN_B, RX_PAN_B); // tx, rx |
soulx | 0:95d17607a698 | 28 | |
soulx | 0:95d17607a698 | 29 | pan_a.baud(115200); |
soulx | 0:95d17607a698 | 30 | pan_b.baud(115200); |
soulx | 0:95d17607a698 | 31 | |
soulx | 0:95d17607a698 | 32 | } |
soulx | 0:95d17607a698 | 33 | |
soulx | 0:95d17607a698 | 34 | void Init_foreground() |
soulx | 0:95d17607a698 | 35 | { |
soulx | 0:95d17607a698 | 36 | Update_command.attach(&setControl,TIMER_UPDATE); |
soulx | 0:95d17607a698 | 37 | Samping.attach(&getSensor,TIMER_SAMPING); |
soulx | 0:95d17607a698 | 38 | } |
soulx | 0:95d17607a698 | 39 | |
soulx | 0:95d17607a698 | 40 | void setControl() |
soulx | 0:95d17607a698 | 41 | { |
soulx | 0:95d17607a698 | 42 | |
soulx | 0:95d17607a698 | 43 | } |
soulx | 0:95d17607a698 | 44 | |
soulx | 0:95d17607a698 | 45 | void getSensor() |
soulx | 0:95d17607a698 | 46 | { |
soulx | 0:95d17607a698 | 47 | |
soulx | 0:95d17607a698 | 48 | } |
soulx | 0:95d17607a698 | 49 | |
soulx | 0:95d17607a698 | 50 | int main() |
soulx | 0:95d17607a698 | 51 | { |
soulx | 0:95d17607a698 | 52 | Init_communication(); |
soulx | 0:95d17607a698 | 53 | Init_servo(); |
soulx | 0:95d17607a698 | 54 | |
soulx | 0:95d17607a698 | 55 | } |