SCRIBE / Mbed 2 deprecated SCRIBE_servo

Dependencies:   BLE_nRF8001 BNO055 HC_SR04_Ultrasonic_Library mbed-rtos mbed

Fork of SCRIBE_stepper by SCRIBE

Files at this revision

API Documentation at this revision

Comitter:
nibab
Date:
Wed May 04 23:32:45 2016 +0000
Parent:
5:1da4d4050306
Child:
7:1bb3b5b66fe8
Commit message:
The servo version. Delete stepper.h and stepper.cpp. Add servo.h and servo.cpp

Changed in this revision

localization.lib Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
servo.cpp Show annotated file Show diff for this revision Revisions of this file
servo.h Show annotated file Show diff for this revision Revisions of this file
stepper.cpp Show diff for this revision Revisions of this file
stepper.h Show diff for this revision Revisions of this file
--- a/localization.lib	Mon Apr 25 05:38:48 2016 +0000
+++ b/localization.lib	Wed May 04 23:32:45 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/SCRIBE/code/localization/#fcdba69a0c22
+https://developer.mbed.org/teams/SCRIBE/code/localization/#91db52943f3e
--- a/mbed-rtos.lib	Mon Apr 25 05:38:48 2016 +0000
+++ b/mbed-rtos.lib	Wed May 04 23:32:45 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#bdd541595fc5
+http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#162b12aea5f2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/servo.cpp	Wed May 04 23:32:45 2016 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+
+PwmOut pin25(p25);
+PwmOut pin26(p26);
+
+void servo_reset(){
+    pin25.period_ms(20); //Set the period: 20ms
+    pin26.period_ms(20); //Set the period: 20ms
+}
+
+void servo_f(){
+    pin25.pulsewidth_us(1300);
+    pin26.pulsewidth_us(1700);
+}
+
+void servo_b(){
+    pin25.pulsewidth_us(1700);
+    pin26.pulsewidth_us(1300);
+}
+
+void servo_right(){
+    pin25.pulsewidth_us(1700);
+    pin26.pulsewidth_us(1700);
+}
+
+void servo_left(){
+    pin25.pulsewidth_us(1300);
+    pin26.pulsewidth_us(1300);
+}
+
+void servo_stop(){
+    pin25.pulsewidth_us(1500);
+    pin26.pulsewidth_us(1515);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/servo.h	Wed May 04 23:32:45 2016 +0000
@@ -0,0 +1,11 @@
+void servo_reset();
+
+void servo_f();
+
+void servo_b();
+
+void servo_left();
+
+void servo_right();
+
+void servo_stop();
\ No newline at end of file
--- a/stepper.cpp	Mon Apr 25 05:38:48 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,319 +0,0 @@
-#include "mbed.h";
-
-DigitalOut yellow_l(p9);
-DigitalOut orange_l(p14);
-DigitalOut brown_l(p15);
-DigitalOut black_l(p16);
-
-DigitalOut yellow_r(p17);
-DigitalOut orange_r(p18);
-DigitalOut brown_r(p19);
-DigitalOut black_r(p20);
-
-int wait_t = 60;
-int case_stepf = 0;
-int case_right = 0;
-int case_left = 0;
-int case_rone = 0;
-
-
-//StepperMotorUni motor( p17, p18, p19, p20);
-int step_f(){
-    switch(case_stepf){
-        case 0:  
-            //step 0101
-            black_l = 0;
-            orange_l = 0;
-            brown_l = 1;
-            yellow_l = 1;
-            black_r = 1;
-            orange_r = 0;
-            brown_r = 0;
-            yellow_r = 1;
-            
-            wait_ms(wait_t);
-            case_stepf=1;
-            break;
-            
-        case 1:
-            //step 1100
-            black_l = 0;
-            orange_l = 1;
-            brown_l = 1;
-            yellow_l = 0;
-            black_r = 1;
-            orange_r = 1;
-            brown_r = 0;
-            yellow_r = 0;
-            
-            wait_ms(wait_t);
-            case_stepf=2;
-            break;
-            
-        case 2:
-            //step 1010
-            black_l = 1;
-            orange_l = 1;
-            brown_l = 0;
-            yellow_l = 0;
-            black_r = 0;
-            orange_r = 1;
-            brown_r = 1;
-            yellow_r = 0;
-            
-            wait_ms(wait_t);
-            case_stepf = 3;
-            break;
-        
-        case 3:
-            //step 0011
-            black_l = 1;
-            orange_l = 0;
-            brown_l = 0;
-            yellow_l = 1;
-            black_r = 0;
-            orange_r = 0;
-            brown_r = 1;
-            yellow_r = 1;
-            
-            wait_ms(wait_t);
-            case_stepf = 0;
-            break;
-    }
-    return 1;
-}
-
-
-int step_b(){ 
-        //step 0101
-    black_r = 0;
-    orange_r = 0;
-    brown_r = 1;
-    yellow_r = 1;
-    black_l = 1;
-    orange_l = 0;
-    brown_l = 0;
-    yellow_l = 1;
-    
-    wait_ms(wait_t);
-    
-    //step 1100
-    black_r = 0;
-    orange_r = 1;
-    brown_r = 1;
-    yellow_r = 0;
-    black_l = 1;
-    orange_l = 1;
-    brown_l = 0;
-    yellow_l = 0;
-    
-    wait_ms(wait_t);
-    
-    //step 1010
-    black_r = 1;
-    orange_r = 1;
-    brown_r = 0;
-    yellow_r = 0;
-    black_l = 0;
-    orange_l = 1;
-    brown_l = 1;
-    yellow_l = 0;
-    
-    wait_ms(wait_t);
-    
-    //step 0011
-    black_r = 1;
-    orange_r = 0;
-    brown_r = 0;
-    yellow_r = 1;
-    black_l = 0;
-    orange_l = 0;
-    brown_l = 1;
-    yellow_l = 1;
-    
-    wait_ms(wait_t);
-
-    return 1;
-}
-
-int step_right(){
-    switch(case_right){
-        case 0:
-            //step 0101
-            black_r = 0;
-            orange_r = 0;
-            brown_r = 1;
-            yellow_r = 1;
-            black_l = 0;
-            orange_l = 0;
-            brown_l = 1;
-            yellow_l = 1;
-            
-            wait_ms(wait_t);
-            case_right = 1;
-            break;
-        
-        case 1:
-            //step 1100
-            black_r = 0;
-            orange_r = 1;
-            brown_r = 1;
-            yellow_r = 0;
-            black_l = 0;
-            orange_l = 1;
-            brown_l = 1;
-            yellow_l = 0;
-            
-            wait_ms(wait_t);
-            case_right = 2;
-            break;
-        
-        
-        case 2:
-            //step 1010
-            black_r = 1;
-            orange_r = 1;
-            brown_r = 0;
-            yellow_r = 0;
-            black_l = 1;
-            orange_l = 1;
-            brown_l = 0;
-            yellow_l = 0;
-            
-            wait_ms(wait_t);
-            case_right = 3;
-            break;
-    
-    
-        case 3:
-            //step 0011
-            black_r = 1;
-            orange_r = 0;
-            brown_r = 0;
-            yellow_r = 1;
-            black_l = 1;
-            orange_l = 0;
-            brown_l = 0;
-            yellow_l = 1;
-            
-            wait_ms(wait_t);
-            case_right = 0;
-            break;
-    }
-    return 1;
-}
-
-
-int step_left(){ 
-    switch(case_left){
-        case 0:
-            //step 0011
-            black_l = 1;
-            orange_l = 0;
-            brown_l = 0;
-            yellow_l = 1;
-            black_r = 1;
-            orange_r = 0;
-            brown_r = 0;
-            yellow_r = 1;
-            
-            wait_ms(wait_t);
-            case_left = 1;
-            break;
-            
-        case 1:
-            black_l = 1;
-            orange_l = 1;
-            brown_l = 0;
-            yellow_l = 0;
-            black_r = 1;
-            orange_r = 1;
-            brown_r = 0;
-            yellow_r = 0;
-            
-            wait_ms(wait_t);
-            case_left = 2;
-            break;
-        
-        case 2:
-            black_l = 0;
-            orange_l = 1;
-            brown_l = 1;
-            yellow_l = 0;
-            black_r = 0;
-            orange_r = 1;
-            brown_r = 1;
-            yellow_r = 0;
-            
-            wait_ms(wait_t);
-            case_left = 3;
-            break;
-        
-        case 3:
-            black_l = 0;
-            orange_l = 0;
-            brown_l = 1;
-            yellow_l = 1;
-            black_r = 0;
-            orange_r = 0;
-            brown_r = 1;
-            yellow_r = 1;
-            
-            wait_ms(wait_t);
-            
-            case_left = 0;
-            break;
-    }
-    return 1;
-}
-
-int step_rone(){
-    switch(case_rone){
-        case 0:
-            //step 0101
-            black_r = 0;
-            orange_r = 0;
-            brown_r = 1;
-            yellow_r = 1;
-            
-            wait_ms(wait_t);
-            case_right = 1;
-            break;
-        
-        case 1:
-            //step 1100
-            black_r = 0;
-            orange_r = 1;
-            brown_r = 1;
-            yellow_r = 0;
-            
-            wait_ms(wait_t);
-            case_right = 2;
-            break;
-        
-        
-        case 2:
-            //step 1010
-            black_r = 1;
-            orange_r = 1;
-            brown_r = 0;
-            yellow_r = 0;
-            
-            wait_ms(wait_t);
-            case_right = 3;
-            break;
-    
-    
-        case 3:
-            //step 0011
-            black_r = 1;
-            orange_r = 0;
-            brown_r = 0;
-            yellow_r = 1;
-            
-            wait_ms(wait_t);
-            case_right = 0;
-            break;
-    }
-    return 1;
-}
--- a/stepper.h	Mon Apr 25 05:38:48 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-int step_f();
-
-int step_b();
-
-int step_left();
-
-int step_right();
-
-int step_rone();
\ No newline at end of file