Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Turret_move.cpp@3:ab87f97bfa06, 2015-03-03 (annotated)
- Committer:
- m166588
- Date:
- Tue Mar 03 14:25:05 2015 +0000
- Revision:
- 3:ab87f97bfa06
- Parent:
- 2:1ef6c6f5dfe1
920 with saturation
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| LanierUSNA16 | 0:e8b029305469 | 1 | #include "mbed.h" |
| LanierUSNA16 | 0:e8b029305469 | 2 | PwmOut turret_speed(p21); |
| LanierUSNA16 | 0:e8b029305469 | 3 | DigitalOut turret_direction(p22); |
| LanierUSNA16 | 0:e8b029305469 | 4 | |
| LanierUSNA16 | 0:e8b029305469 | 5 | |
| LanierUSNA16 | 0:e8b029305469 | 6 | int main() |
| LanierUSNA16 | 0:e8b029305469 | 7 | { |
| LanierUSNA16 | 1:f60fe84699b4 | 8 | int input_dc =50; |
| LanierUSNA16 | 1:f60fe84699b4 | 9 | int user_direction = 0; |
| LanierUSNA16 | 1:f60fe84699b4 | 10 | float duty_cycle = 0.6; |
| LanierUSNA16 | 0:e8b029305469 | 11 | |
| LanierUSNA16 | 0:e8b029305469 | 12 | while(1) |
| LanierUSNA16 | 0:e8b029305469 | 13 | { |
| LanierUSNA16 | 2:1ef6c6f5dfe1 | 14 | printf("Enter duty cycle, 0 to 100:\n"); |
| LanierUSNA16 | 1:f60fe84699b4 | 15 | scanf("%d", &input_dc); |
| LanierUSNA16 | 2:1ef6c6f5dfe1 | 16 | duty_cycle = input_dc/100.0; |
| m166588 | 3:ab87f97bfa06 | 17 | if (duty_cycle >=1.0) |
| m166588 | 3:ab87f97bfa06 | 18 | { |
| m166588 | 3:ab87f97bfa06 | 19 | duty_cycle = 1.0; |
| m166588 | 3:ab87f97bfa06 | 20 | } |
| m166588 | 3:ab87f97bfa06 | 21 | if (duty_cycle <= 0.0) |
| m166588 | 3:ab87f97bfa06 | 22 | { |
| m166588 | 3:ab87f97bfa06 | 23 | duty_cycle = 0.0; |
| m166588 | 3:ab87f97bfa06 | 24 | } |
| LanierUSNA16 | 1:f60fe84699b4 | 25 | |
| LanierUSNA16 | 2:1ef6c6f5dfe1 | 26 | printf("%f duty cycle set. Enter 0 for CCW or 1 for CW spin direction:\n",duty_cycle); |
| LanierUSNA16 | 1:f60fe84699b4 | 27 | scanf("%d", &user_direction); |
| LanierUSNA16 | 1:f60fe84699b4 | 28 | |
| LanierUSNA16 | 1:f60fe84699b4 | 29 | turret_speed = duty_cycle; |
| LanierUSNA16 | 1:f60fe84699b4 | 30 | turret_direction = user_direction; |
| LanierUSNA16 | 2:1ef6c6f5dfe1 | 31 | printf("%f duty cycle. %d spin.\n", duty_cycle, user_direction); |
| LanierUSNA16 | 1:f60fe84699b4 | 32 | |
| LanierUSNA16 | 0:e8b029305469 | 33 | } |
| LanierUSNA16 | 1:f60fe84699b4 | 34 | } |