SEU10f / Mbed 2 deprecated p3_modexy

Dependencies:   mbed

Fork of p2_analogin by Sergio Moyano

Files at this revision

API Documentation at this revision

Comitter:
Sersd
Date:
Tue Sep 29 18:02:37 2015 +0000
Parent:
0:00529fca1abf
Commit message:
bn

Changed in this revision

hello.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/hello.cpp	Tue Sep 29 16:53:55 2015 +0000
+++ b/hello.cpp	Tue Sep 29 18:02:37 2015 +0000
@@ -1,48 +1,34 @@
 // Flash an LED while a DigitalIn is true
  
 #include "mbed.h"
- 
-AnalogIn   ain(p15);
-Serial pc(USBTX, USBRX); // tx, rx
+
 
-float media=0;
-float alpha=0.99;
-float actual=0;
-float offset=0.001;
+PwmOut pwmx(p26);
+PwmOut pwmy(p21);
+
+
+float pointx[] = {(0.00),(0.01),(0.02)};
+float pointy[] = {(0.00),(0.02),(0.00)};
 
-int contador=0;
-
-char state =0;
-char prev_state=0;
-int timeini;
-int timefi;
-Timer timer;
 int main() {
-  
-    media= ain.read();
-    timer.start();
+    
+ //   Matrix myMatrix(4,2);
+ //   Matrix anotherMatrix;
+ 
+    // Fill Matrix with data.
+ //   myMatrix << 2  << 2  << 3
+ //            << 4  << 5  << 6;
+             
+    pwmx.period(0.02f);  // 4 second period
+    pwmy.period(0.02f); 
+                
     while(1) {
-        actual=ain;
-      //  pc.printf("actual %f \n\r",actual);
-       // pc.printf("media %f \n\r",media);
-        media=media*alpha+(1-alpha)*actual;
-        if((actual-media) > offset){
-            state=1;
-            if(prev_state==0){
-                if(contador==0){
-                      timeini = timer.read_us();  
-                      contador++; 
-                }else if(contador==1){   
-                      timefi = timer.read_us();  
-                      pc.printf("Periode %d \n\r",timefi-timeini);
-                      contador=0;
-                }
-            }
-        }else if((actual-media) < offset){
-            state=0;
-            
+       for(int i=0;i<3;i++){ 
+           pwmx.pulsewidth(pointx[i]); 
+           pwmy.pulsewidth(pointy[i]); 
+           wait(0.02f);
         }
-        prev_state = state;
-        wait(0.0002);
     }
-}
+    
+    
+}
\ No newline at end of file