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@1:f60fe84699b4, 2015-03-03 (annotated)
- Committer:
- LanierUSNA16
- Date:
- Tue Mar 03 13:55:15 2015 +0000
- Revision:
- 1:f60fe84699b4
- Parent:
- 0:e8b029305469
- Child:
- 2:1ef6c6f5dfe1
turret 2;
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 | 1:f60fe84699b4 | 14 | |
| LanierUSNA16 | 1:f60fe84699b4 | 15 | printf("input_dc= %d \n user_direction = %d \n duty_cycle = %f \n", input_dc, user_direction, duty_cycle); |
| LanierUSNA16 | 0:e8b029305469 | 16 | |
| LanierUSNA16 | 1:f60fe84699b4 | 17 | wait(2); |
| LanierUSNA16 | 1:f60fe84699b4 | 18 | |
| LanierUSNA16 | 1:f60fe84699b4 | 19 | printf("Enter duty cycle:\n"); |
| LanierUSNA16 | 1:f60fe84699b4 | 20 | scanf("%d", &input_dc); |
| LanierUSNA16 | 1:f60fe84699b4 | 21 | duty_cycle = input_dc/100.0; |
| LanierUSNA16 | 1:f60fe84699b4 | 22 | |
| LanierUSNA16 | 1:f60fe84699b4 | 23 | printf("input_dc= %d \n user_direction = %d \n duty_cycle = %f \n", input_dc, user_direction, duty_cycle); |
| LanierUSNA16 | 1:f60fe84699b4 | 24 | |
| LanierUSNA16 | 1:f60fe84699b4 | 25 | wait(2); |
| LanierUSNA16 | 0:e8b029305469 | 26 | |
| LanierUSNA16 | 1:f60fe84699b4 | 27 | printf("%f duty cycle set. Enter 0 or 1 for spin direction:\n",duty_cycle); |
| LanierUSNA16 | 1:f60fe84699b4 | 28 | scanf("%d", &user_direction); |
| LanierUSNA16 | 1:f60fe84699b4 | 29 | |
| LanierUSNA16 | 1:f60fe84699b4 | 30 | printf("input_dc= %d \n user_direction = %d \n duty_cycle = %f \n", input_dc, user_direction, duty_cycle); |
| LanierUSNA16 | 1:f60fe84699b4 | 31 | |
| LanierUSNA16 | 1:f60fe84699b4 | 32 | wait(2); |
| LanierUSNA16 | 1:f60fe84699b4 | 33 | |
| LanierUSNA16 | 1:f60fe84699b4 | 34 | turret_speed = duty_cycle; |
| LanierUSNA16 | 1:f60fe84699b4 | 35 | turret_direction = user_direction; |
| LanierUSNA16 | 1:f60fe84699b4 | 36 | printf("%f duty cycle. %d spin.\n", duty_cycle, turret_direction); |
| LanierUSNA16 | 1:f60fe84699b4 | 37 | |
| LanierUSNA16 | 0:e8b029305469 | 38 | } |
| LanierUSNA16 | 1:f60fe84699b4 | 39 | } |