Tarea1-Versión3. Uso de 3 botones, al presionar el botón 1 el tiempo de encendido y apagado del LED disminuye, al presionar el botón 2 el tiempo de encendido y apagado del LED aumenta, al presionar el botón 3 se lleva el LED a un estado inicial (Reset)

Dependencies:   Debounced mbed

Fork of Tarea1-V3 by junior andres calle acevedo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 #include "mbed.h"
00003 #include "DebouncedIn.h"
00004 
00005 DebouncedIn puls1(PTC12);
00006 DebouncedIn puls2(PTC13);
00007 DebouncedIn puls3(PTC16);
00008 DigitalOut myled(LED1);
00009 
00010 float k=0;
00011 float t=0.01;
00012 float r=0;
00013 
00014 int main() {
00015     while(1) {
00016         if(puls1.falling()){
00017             ++k;
00018             t=0.01*(k*1.1);
00019            }
00020         myled = !myled;
00021         wait(t); 
00022         if (puls2.falling()){
00023             --k;
00024             t=0.01*(k*1.1);}
00025         myled=!myled;
00026         wait(t); 
00027         if(puls3.falling()){
00028           k=1;
00029           t=0.01;
00030            }
00031         myled=!myled;
00032         wait(t);
00033         }
00034             
00035 }
00036