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.
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 #include "DebouncedIn.h" 00004 00005 Timer timer1; 00006 TextLCD lcd(PTC10, PTC11, PTC12, PTC13, PTC16, PTC17); // rs, e, d4-d7TextLCD lcd(PTC10, PTC11, PTC12, PTC13, PTC16, PTC17); // rs, e, d4-d7 00007 DebouncedIn Arriba(PTE2); 00008 DebouncedIn Abajo(PTE3); 00009 DigitalOut myled(LED1); 00010 00011 int i; 00012 00013 int main() { 00014 00015 lcd.cls(); 00016 lcd.printf("Conteo:%d", i); 00017 00018 while(1){ 00019 00020 00021 if(Arriba.falling()||Abajo.falling()){ 00022 timer1.start(); 00023 } 00024 while(Arriba==0||Abajo==0){ 00025 if(Arriba==1&&Abajo==1){ 00026 timer1.stop(); 00027 timer1.reset(); 00028 00029 } 00030 if (timer1.read()>0&&timer1.read()<=5&&Arriba==0&&i>=0&&i<=1000) { 00031 ++i; 00032 myled=1; 00033 wait(0.3); 00034 myled=0; 00035 wait(0.3); 00036 00037 } 00038 if (timer1.read()>0&&timer1.read()<=5&&Abajo==0&&i>=0&&i<=1000) { 00039 --i; 00040 myled=1; 00041 wait(0.3); 00042 myled=0; 00043 wait(0.3); 00044 00045 } 00046 00047 if (timer1.read()>5&&timer1.read()<=10&&Arriba==0&&i>=0&&i<=1000) { 00048 i+=5; 00049 myled=1; 00050 wait(0.3/5); 00051 myled=0; 00052 wait(0.3/5); 00053 00054 } 00055 if (timer1.read()>5&&timer1.read()<=10&&Abajo==0&&i>=0&&i<=1000) { 00056 i-=5; 00057 myled=1; 00058 wait(0.3/5); 00059 myled=0; 00060 wait(0.3/5); 00061 00062 } 00063 00064 00065 if (timer1.read()>10&&timer1.read()<=100&&Arriba==0&&i>=0&&i<=1000) { 00066 i+=10; 00067 00068 myled=1; 00069 wait(0.03); 00070 myled=0; 00071 wait(0.03); 00072 00073 } 00074 if (timer1.read()>10&&timer1.read()<=100&&Abajo==0&&i>=0&&i<=1000) { 00075 i-=10; 00076 00077 myled=1; 00078 wait(0.03); 00079 myled=0; 00080 wait(0.03); 00081 00082 } 00083 if(i<0){ 00084 i=0; 00085 } 00086 00087 if(i>1000){ 00088 i=1000; 00089 } 00090 i=i; 00091 lcd.locate(7,0); 00092 lcd.printf(" "); 00093 lcd.locate(8,0); 00094 lcd.printf("%d", i); 00095 wait(0.2); 00096 00097 00098 } 00099 } 00100 } 00101 00102 00103 00104
Generated on Sat Jul 16 2022 10:33:49 by
1.7.2