ggg

Dependencies:   Motor mbed

Files at this revision

API Documentation at this revision

Comitter:
matthewhall115
Date:
Fri Mar 09 02:54:18 2018 +0000
Commit message:
yo

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Fri Mar 09 02:54:18 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/Motor/#f265e441bcd9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Mar 09 02:54:18 2018 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#include "Motor.h"  // program to drive DC motor
+#define PI (3.14159)  //define PI to make life easy 
+
+PwmOut led(LED2);     //define led
+Motor m(p21,p22,p22); //define pins for MBED/TD340 communication
+
+//Declare global variables for data handling
+char c;  //declaring character 'c'
+float dc; //float called dc, duty cycle
+
+int main ()     //main function
+{
+
+
+    while(1) {
+        led=0;          //LED off
+        m.speed(0);     //motor is off
+        c = getchar();   //get character inpput from user
+
+
+        if (c == 'l') {     //if the character 'l' is pressed
+            led != led;
+            printf("Enter Duty Cycle in +0.XX form to move left: \n\n"); //asking for user input
+            scanf("%f", &dc);   //storing user input
+            puts("Moving left!\n\n");
+            m.speed(dc);  //moving the motor at the user's desired duty cycle
+            wait(6);  //spins for 6 seconds
+        }//end if
+
+        if (c == 'r') {        //if the character 'r' is pressed
+            led != led;
+            printf("Enter Duty Cycle in -0.XX form to move right: \n\n"); //asking for user input
+            scanf("%f", &dc);   //storing user input
+            puts("Moving right!\n\n"); 
+            m.speed(dc);  //moving the motor at the user's desired duty cycle
+            wait(6);  //spins for 6 seconds
+        }//end if
+
+    } //end while
+
+} //end main(1)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 09 02:54:18 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5571c4ff569f
\ No newline at end of file