Ejercicio N°1: Parpadeo de un led controlado por un pulsador

Dependencies:   KL25N_TPN1_EJN1 TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
JAgustinOtero
Date:
Tue Jun 05 23:32:50 2018 +0000
Commit message:
Ejercicio N?1:; Parpadeo de un led controlado por un pulsador

Changed in this revision

KL25N_TPN1_EJN1.lib Show annotated file Show diff for this revision Revisions of this file
TSI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KL25N_TPN1_EJN1.lib	Tue Jun 05 23:32:50 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/JAgustinOtero/code/KL25N_TPN1_EJN1/#44f073a9d163
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Tue Jun 05 23:32:50 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 05 23:32:50 2018 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+#include "TSISensor.h"
+#include "ME_Parpadeo.h"
+#define apagado 1
+#define prendido 0
+#define presionado 1
+#define no_presionado 0
+char a=1;
+
+DigitalIn entrada (PTE1);
+DigitalOut led(LED3);
+
+char pulsador=0;
+char l=0;
+
+Ticker readP;
+Ticker parpadeoL;
+
+void antirebote(void);
+void parpadeoLED(void);
+
+int main()
+{
+    char b=0;
+    led=apagado;
+    TSISensor tsi;
+    readP.attach(&antirebote,0.001);
+    parpadeoL.attach(&parpadeoLED,0.5);
+    while(1) {
+        b=enable(pulsador);//esta funcion se encarga de habilitar o deshabilitar el parpadeo del led cuando se presiona el pulsador
+        parpadeo(b);//esta funcion se encarga de realizar el parpadeo del led
+        if(entrada==1 && l==0 && pulsador!=1) l=10;
+    }
+}
+
+void parpadeoLED(void)// esta funcion es el ticker vinculado al parpadeo del led
+{
+    parpadeo_estado=!parpadeo_estado;
+}
+
+void antirebote()// esta funcion se encarga de sacarle el rebote al pulsador
+{
+    if(entrada==1 && l>0) l--;
+    if(l==0 && entrada==1) pulsador=1;
+    else pulsador=0;
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 05 23:32:50 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/994bdf8177cb
\ No newline at end of file