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
Diff: Turret_move.cpp
- Revision:
- 1:f60fe84699b4
- Parent:
- 0:e8b029305469
- Child:
- 2:1ef6c6f5dfe1
--- a/Turret_move.cpp Tue Mar 03 13:36:47 2015 +0000
+++ b/Turret_move.cpp Tue Mar 03 13:55:15 2015 +0000
@@ -2,32 +2,38 @@
PwmOut turret_speed(p21);
DigitalOut turret_direction(p22);
-float duty_cycle = 0;
-int user_direction = 0;
int main()
{
+int input_dc =50;
+int user_direction = 0;
+float duty_cycle = 0.6;
while(1)
-{
-printf("Enter duty cycle:");
-scanf("%f", &duty_cycle);
-
-printf("%f duty cycle set. Enter 0 or 1 for spin direction:");
-scanf("%d", &user_direction);
-
-if (duty_cycle< 1.0 && duty_cycle>-1.0)
{
- turret_speed = duty_cycle;
- turret_direction = user_direction;
-
- }
+
+ printf("input_dc= %d \n user_direction = %d \n duty_cycle = %f \n", input_dc, user_direction, duty_cycle);
- else
+ wait(2);
+
+ printf("Enter duty cycle:\n");
+ scanf("%d", &input_dc);
+ duty_cycle = input_dc/100.0;
+
+ printf("input_dc= %d \n user_direction = %d \n duty_cycle = %f \n", input_dc, user_direction, duty_cycle);
+
+ wait(2);
- {
- printf("need to saturate");
+ printf("%f duty cycle set. Enter 0 or 1 for spin direction:\n",duty_cycle);
+ scanf("%d", &user_direction);
+
+ printf("input_dc= %d \n user_direction = %d \n duty_cycle = %f \n", input_dc, user_direction, duty_cycle);
+
+ wait(2);
+
+ turret_speed = duty_cycle;
+ turret_direction = user_direction;
+ printf("%f duty cycle. %d spin.\n", duty_cycle, turret_direction);
+
}
- }
- }
-
\ No newline at end of file
+}
\ No newline at end of file