Code for LHS 12_12_2013

Dependencies:   Servo mbed

Revision:
1:da313e5e8914
Parent:
0:17b1dcf89648
Child:
2:da289f7a67c9
--- a/main.cpp	Fri Dec 13 02:06:17 2013 +0000
+++ b/main.cpp	Sat Feb 01 16:47:22 2014 +0000
@@ -1,6 +1,17 @@
+//==================================
+//
+//          PLTW PROGRAM
+//   ----------------------------
+// Controls a PWM output using 
+// digital inputs
+//
+//==================================
+
+
 //==================================
 // Add any libraries that you use:
 //==================================
+
 #include "mbed.h"
 #include "Servo.h"
 
@@ -9,11 +20,11 @@
 // Add variables:
 //==================================
 
-//add a servo to PWM output on pin 25
-Servo myservo(p25);
+//add a motor to PWM output on pin 25
+Servo motor1(p25);
 
-//add a variable for servo position
-float position = 0.5;
+//add a variable for motor speed
+float speed = 0.5;
 
 //add variables for the onboard LEDS, which display for each button
 DigitalOut led1(LED1), led2(LED2), led3(LED3), led4(LED4);
@@ -29,9 +40,9 @@
 // Functions for button 1
 void a_hit_interrupt (void) {
 
-    //move servo motor
-    position = 1.0;
-    myservo = position;
+    //move VEX motor
+    speed = 1.0;
+    motor1 = speed;
     
     //Set LED 1
     led1 = 1, led2 = 0, led3 = 0, led4 = 0;
@@ -42,9 +53,9 @@
 // Functions for button 2
 void b_hit_interrupt (void) {
 
-    //move servo motor
-    position = 0.0;
-    myservo = position;
+    //move VEX motor
+    speed = 0.0;
+    motor1 = speed;
     //Set LED 2
     led1 = 0, led2 = 1, led3 = 0, led4 = 0;    
 }
@@ -76,7 +87,7 @@
 
 int main() {
 
-    //tune range depending on servo motor
+    //tune range depending on VEX motor
     float range = 0.0009;
        
     // Use internal pullup resistors to limit the signal current
@@ -96,8 +107,8 @@
     
     
     while(1) { 
-        //set the servo to use the set value
-        myservo.calibrate(range, 45.0); 
+        //set the VEX to use the set value
+        motor1.calibrate(range, 45.0); 
         
         //reset LEDs
         led1 = 0, led2 = 0, led3 = 0, led4 = 0;