Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 1:7b39e7307343, committed 2018-05-03
- Comitter:
- Tom_87
- Date:
- Thu May 03 23:33:41 2018 +0000
- Parent:
- 0:2834a9185461
- Commit message:
- Debounce Program
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PRUEBA1_LIB_ANTIREBOTE.cpp Thu May 03 23:33:41 2018 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "antirrebote.h"
+
+DigitalOut LR(LED1);
+DigitalOut LV(LED2);
+
+
+AntReb detector_pulso;
+
+Ticker timer;
+
+char tiempo = 15;
+
+void attime(void);
+
+int main()
+{ LR = 1;
+ LV = 1;
+ char prendete = 1;
+ timer.attach(&attime, 0.001);
+ while(1)
+ {
+ detector_pulso.setPin(PTE5);
+ if(tiempo == 0)
+ {
+ tiempo = 15;
+ prendete = detector_pulso.antiRebote();
+ }
+ if(prendete == 0)
+ LR = 0;
+ if (prendete==1)
+ LR=1;
+ }
+}
+
+void attime (void)
+{
+ if(tiempo > 0){
+ tiempo--;
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/antirrebote.lib Thu May 03 23:33:41 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/Sistemas-Embebidos/code/antirrebote/#16d62113f1d5
--- a/main.cpp Wed Apr 18 23:58:24 2018 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#include "mbed.h"
-#define TIME 0.001
-
-enum{ENCENDIDO, APAGADO};
-enum{NO_APRETADO, APRETADO};
-enum{PULS_NA, PULS_FLC1, PULS_A, PULS_FLC2};
-
-Ticker timer;
-
-DigitalIn PULS(PTB8);
-DigitalOut LED_R(LED1);
-
-unsigned char e_PULS = PULS_NA;
-unsigned char PULS_tout = 5;
-unsigned char OUT;
-
-void SET_UP(void);
-void attime(void);
-void PULS_Step(void);
-
-int main(void) {
- SET_UP();
-
- while(1) {
- PULS_Step();
- }
-}
-
-void SET_UP(void){
- timer.attach(&attime,TIME);
-}
-
-void PULS_Step(void){
- switch(e_PULS){
- default:
- case PULS_NA:
- LED_R = APAGADO;
- if(PULS == APRETADO && PULS_tout == 0) {
- e_PULS = PULS_FLC1;
- PULS_tout = 5;
- }
- break;
- case PULS_FLC1:
- LED_R = APAGADO;
- if(PULS == APRETADO && PULS_tout == 0) {
- e_PULS = PULS_A;
- PULS_tout = 5;
- LED_R = ENCENDIDO;
- }else if(PULS == NO_APRETADO) {
- e_PULS = PULS_NA;
- }
- break;
- case PULS_A:
- LED_R = APAGADO;
- if(PULS == NO_APRETADO && PULS_tout == 0) {
- e_PULS = PULS_FLC2;
- PULS_tout = 5;
- }
- break;
- case PULS_FLC2:
- LED_R = APAGADO;
- if(PULS == APRETADO) {
- e_PULS = PULS_A;
- }else if(PULS == NO_APRETADO && PULS_tout == 0) {
- e_PULS = PULS_NA;
- PULS_tout = 5;
- }
- break;
- }
-}
-
-void attime(void) {
- if (PULS_tout > 0) {
- PULS_tout--;
- }
-}
\ No newline at end of file
--- a/mbed.bld Wed Apr 18 23:58:24 2018 +0000 +++ b/mbed.bld Thu May 03 23:33:41 2018 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/mbed_official/code/mbed/builds/994bdf8177cb \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/prog_in_antirrebote.cpp Thu May 03 23:33:41 2018 +0000
@@ -0,0 +1,76 @@
+/*#include "mbed.h"
+
+enum{ENCENDIDO, APAGADO};
+enum{NO_APRETADO, APRETADO};
+enum{PULS_NA, PULS_FLC1, PULS_A, PULS_FLC2};
+
+Ticker timer;
+
+DigitalIn PULS(PTB8);
+DigitalOut LED_R(LED1);
+
+unsigned char e_PULS = PULS_NA;
+unsigned char PULS_tout = 5;
+unsigned char OUT;
+
+void SET_UP(void);
+void attime(void);
+void PULS_Step(void);
+
+int main(void) {
+ SET_UP();
+
+ while(1) {
+ PULS_Step();
+ }
+}
+
+void SET_UP(void){
+ timer.attach(&attime,TIME);
+}
+
+void PULS_Step(void){
+ switch(e_PULS){
+ default:
+ case PULS_NA:
+ LED_R = APAGADO;
+ if(PULS == APRETADO && PULS_tout == 0) {
+ e_PULS = PULS_FLC1;
+ PULS_tout = 5;
+ }
+ break;
+ case PULS_FLC1:
+ LED_R = APAGADO;
+ if(PULS == APRETADO && PULS_tout == 0) {
+ e_PULS = PULS_A;
+ PULS_tout = 5;
+ LED_R = ENCENDIDO;
+ }else if(PULS == NO_APRETADO) {
+ e_PULS = PULS_NA;
+ }
+ break;
+ case PULS_A:
+ LED_R = APAGADO;
+ if(PULS == NO_APRETADO && PULS_tout == 0) {
+ e_PULS = PULS_FLC2;
+ PULS_tout = 5;
+ }
+ break;
+ case PULS_FLC2:
+ LED_R = APAGADO;
+ if(PULS == APRETADO) {
+ e_PULS = PULS_A;
+ }else if(PULS == NO_APRETADO && PULS_tout == 0) {
+ e_PULS = PULS_NA;
+ PULS_tout = 5;
+ }
+ break;
+ }
+}
+
+void attime(void) {
+ if (PULS_tout > 0) {
+ PULS_tout--;
+ }
+}
+*/
\ No newline at end of file