programa de parpadeo de leds

Dependencies:   mbed

Fork of Sonar-HC-SR04 by Nestor Pereira-Neto

Files at this revision

API Documentation at this revision

Comitter:
FannyCalle
Date:
Fri Aug 24 22:20:15 2018 +0000
Parent:
0:b0a3597dffa9
Commit message:
parpadeo de tres leds para stm32f411re

Changed in this revision

HC-SR04.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b0a3597dffa9 -r 736c439b72d4 HC-SR04.lib
--- a/HC-SR04.lib	Thu Feb 05 19:04:15 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/Nestordp/code/HC-SR04/#d1d7bb1c1f6c
diff -r b0a3597dffa9 -r 736c439b72d4 main.cpp
--- a/main.cpp	Thu Feb 05 19:04:15 2015 +0000
+++ b/main.cpp	Fri Aug 24 22:20:15 2018 +0000
@@ -1,17 +1,46 @@
 #include "mbed.h"
-#include "HCSR04.h"
-
 DigitalOut myled(LED1);
 Serial pc(USBTX,USBRX);     
-
-HCSR04 sonar(A2, D12);
+PwmOut mypwm(D3);
+DigitalOut uno(PA_0);
+DigitalOut dos(PA_1);
+DigitalOut tres(PA_4);
+InterruptIn button(USER_BUTTON);
 
 int main() {
-    printf("INICIO PROGRAMA\n");
-    while(1) {
-        printf("Distancia detectada pelo sensor Frente %.2f cm \n", sonar.getCm()); 
-        wait_ms(1000);
-        printf("Distancia detectada pelo sensor Frente %.2f in \n", sonar.getIn()); 
-        wait_ms(1000);
+    pc.printf("INICIO PROGRAMA\n");
+    //float dato;
+    while(1)
+    {
+    while(button==1)
+    {
+    uno=1;
+    dos=0;
+    tres=0;
+    wait(.2);
+    uno=0;
+    dos=1;
+    tres=0;
+    wait(0.2);
+    uno=0;
+    dos=0;
+    tres=1;
+    wait(0.2);
+    }
+    while(button==0)
+    {
+    uno=0;
+    dos=0;
+    tres=1;
+    wait(.2);
+    uno=0;
+    dos=1;
+    tres=0;
+    wait(0.2);
+    uno=1;
+    dos=0;
+    tres=0;
+    wait(0.2);
+    }
     }
 }
\ No newline at end of file