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.
Revision 25:86b50a023d28, committed 2020-04-12
- Comitter:
- nervy
- Date:
- Sun Apr 12 03:58:02 2020 +0000
- Parent:
- 24:7f14b70fc9ef
- Commit message:
- e4p3
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Apr 08 11:03:25 2019 +0100 +++ b/main.cpp Sun Apr 12 03:58:02 2020 +0000 @@ -1,12 +1,88 @@ -#include "mbed.h" +//Generar un programa capaz de crear un contador binario de 0 a 5 (000 – 101)ascendente cuando un botón propio de la tarjeta esta presionado, en caso de no estar presionado el contador deberá ir en sentido contrario, es decir de 5 a 0, la secuencia debe ser cíclica. + +#include "mbed.h" //librería que nos permite utilizar comandos y sentencias propias de mbed -DigitalOut myled(LED1); +DigitalIn enable(SW2); +DigitalOut un(LED3); +DigitalOut deux(LED2); +DigitalOut trois(LED1); int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + while(1) + { + if(enable == 1) { + //zero + un = 0; + deux=0; + trois=0; + wait(1); + + //un + un = 0; + deux=0; + trois=1; + wait(1); + + //deux + un = 0; + deux=1; + trois=0; + wait(1); + + //trois + un=0; + deux=1; + trois=1; + wait(1); + + //quatre + un=1; + deux=0; + trois=0; + wait(1); + + //cinq + un=1; + deux=0; + trois=1; + wait(1); + } else { + //cinq + un=1; + deux=0; + trois=1; + wait(1); + + //quatre + un=1; + deux=0; + trois=0; + wait(1); + + //trois + un=0; + deux=1; + trois=1; + wait(1); + + //deux + un = 0; + deux=1; + trois=0; + wait(1); + + //un + un=0; + deux=0; + trois=1; + wait(1); + + //zero + un=0; + deux=0; + trois=0; + wait(1); + } -} + } +} \ No newline at end of file