Lab 7 part 1

Dependencies:   Motor Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
TheDoctor822
Date:
Mon Apr 18 01:37:20 2016 +0000
Commit message:
Lab7 Part 1

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
Servo.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
diff -r 000000000000 -r 64ecc6f5f9c6 Motor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Mon Apr 18 01:37:20 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Motor/#f265e441bcd9
diff -r 000000000000 -r 64ecc6f5f9c6 Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Mon Apr 18 01:37:20 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 64ecc6f5f9c6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 18 01:37:20 2016 +0000
@@ -0,0 +1,57 @@
+/************************************************************************************
+Lab 07 - Part 1
+This program takes in an integer and three float values from the user. It uses
+    the integer as a start trigger and increments the lights on the mbed to match
+    the float values by increments of 0.01.
+MIDN 3/C Drew Moore
+24 FEB 2016
+***********************************************************************************/
+
+
+#include "mbed.h"
+#include "Motor.h"
+#include "Servo.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+Motor motor(p26, p30, p29);
+
+int main() {
+    
+    float speed = 0.0;
+    char userInput;
+    
+    motor.speed ( 0.0 );
+    
+    while(1) {
+        
+        pc.printf ( "Enter either u or d: " );
+        pc.scanf( "%c", &userInput );
+        pc.printf ( "\n" );
+        
+        if ( userInput == 'u' ) {
+            
+            if ( speed < 1.0 ) {
+            
+                speed += 0.1;    
+                motor.speed (speed);
+                pc.printf( "Speed = %f\n", speed );  
+            
+            }
+            
+            else pc.printf ("Cannot increment - Max Positive Speed reached\n" );
+        }
+        
+        if ( userInput == 'd' ) {
+            
+            if ( speed > -1.0 ) {
+                
+                speed -= 0.1;    
+                motor.speed (speed);
+                pc.printf( "Speed = %f\n", speed );  
+            }
+            
+            else pc.printf ("Cannot increment - Max Negative Speed reached\n" );
+        }
+    }
+}
diff -r 000000000000 -r 64ecc6f5f9c6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Apr 18 01:37:20 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file