Juan Manuel Gómez / Mbed 2 deprecated tarea2

Dependencies:   DebouncedIn mbed

Files at this revision

API Documentation at this revision

Comitter:
juanmglopez
Date:
Sun Apr 27 00:20:08 2014 +0000
Parent:
2:a6945fdfc6dd
Commit message:
actualizaci?n de sonidos

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Apr 26 22:55:19 2014 +0000
+++ b/main.cpp	Sun Apr 27 00:20:08 2014 +0000
@@ -10,8 +10,31 @@
 DebouncedIn mybutton2(PTC13);
 DebouncedIn mybutton3(PTC16);
 DigitalOut myled(LED1); // En este caso LED1 se refiere al LED AZUL.
+PwmOut Pwm(PTA5);
  
 float inc = 0.001; // Se establece un retardo inicial de 1 ms.
+float p1 = 0.001;
+
+int PWMmodule(float p1)
+{
+    Pwm.period(p1);
+    Pwm.write(0.1);
+    wait(0.1);
+    Pwm.write(1);
+    wait(0.1);
+    Pwm.write(0.5);
+    wait(0.1);
+    Pwm.write(2);
+    wait(0.1);
+    Pwm.write(0.01);
+    wait(0.1);
+    Pwm.write(0.001);
+    wait(0.1);
+    Pwm.write(0);
+    return 0;
+}
+
+
 
 int main() // Función que define la sucesión entre los diferentes estados del LED
 {
@@ -19,14 +42,25 @@
         if (mybutton1.falling())
         {
             inc += 0.01;
+            PWMmodule(p1);
         }
-        if (mybutton2.falling() && inc != 0.001)
+        if (mybutton2.falling() && inc != 0.001) //Revisar fallo al hundir este botón de primero.
         {   
-            inc -= 0.01;  
+            inc -= 0.01;
+            PWMmodule(p1);  
         }        
         if (mybutton3.falling() && inc != 0.001)
         {
             inc = 0.001;
+            PWMmodule(p1);
+        }
+        if (mybutton2.falling() && inc == 0.001)
+        {   
+            //inc = inc;  
+        }        
+        if (mybutton3.falling() && inc == 0.001)
+        {
+            //inc = inc;
         }
         myled = !myled;
         wait(inc);