Servo position controlled by potvalue

Dependencies:   Servo

Files at this revision

API Documentation at this revision

Comitter:
MMartens
Date:
Fri Oct 20 06:58:16 2017 +0000
Parent:
2:cef1384d2231
Commit message:
Servo position control - full speed

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r cef1384d2231 -r 640691434e7e main.cpp
--- a/main.cpp	Thu Oct 12 14:35:20 2017 +0000
+++ b/main.cpp	Fri Oct 20 06:58:16 2017 +0000
@@ -37,56 +37,18 @@
 
 
 int main() {
-    printf("Servo Calibration Controls:\n");
-    printf("1,2,3 - Position Servo (full left, middle, full right)\n");
-    printf("4,5 - Decrease or Increase range\n");
  
     float range_servo = 0.0008;
     float position_servo = 0.5;
     
     pc.baud(9600);
-    potmeterreadout.attach(readpot,0.05f);
+    potmeterreadout.attach(readpot,0.01f);
     PWM1.period(servo_period);
     
     while(1){            
-        // Safety features to override potvalue       
-        /*switch(pc.getc()) {
-            case '1': position_servo = 0.0; break;
-            case '2': position_servo = 0.5; break;
-            case '3': position_servo = 1.0; break;
-            case '4': range_servo += 0.0001; break; 
-            case '5': range_servo -= 0.0001; break; 
-        }
-        */
-        //printf("position = %.1f, range = +/-%0.4f\r", position_servo, range_servo);
-        //myservo.calibrate(range_servo, 110.0); 
-        //myservo = position_servo;
+
     }
 }
 
-/* Example code to control the servomotor by a potentiometer, similarly one could control the speed of the servomotor. 
-The speed can be controlled by using the library VarSpeedServo.h 
-By mapping the intensity of EMG signal to a range of values (e.g. 0:1:100) you can easily control the speed and position of the motor
-*/
 
-/*
- Servo servo_test;      //initialize a servo object for the connected servo  
-                
- int angle = 0;    
- int potentio = A0;      // initialize the A0analog pin for potentiometer
-
- 
- void setup() 
- { 
-  servo_test.attach(9);     // attach the signal pin of servo to pin9 of arduino
- } 
- 
- void loop() 
- { 
-  angle = analogRead(potentio);            // reading the potentiometer value between 0 and 1023 
-  angle = map(angle, 0, 1023, 0, 179);     // scaling the potentiometer value to angle value for servo between 0 and 180) 
-  servo_test.write(angle);                   //command to rotate the servo to the specified angle 
-  delay(5);             
- }  
- */
  
\ No newline at end of file