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.
Diff: main.cpp
- Revision:
- 0:da682e9c8855
diff -r 000000000000 -r da682e9c8855 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 12 07:08:53 2020 +0000 @@ -0,0 +1,43 @@ +#include "mbed.h" //P4E5 +Serial comunication(USBTX, USBRX); +DigitalIn boton(p13); +//Estructura de control repititiva para envir las suma de cinco números consecutivos cada vez que se presione un botóndebe enviar nuevamente la suma +// y al presionarlo debe enviar nuevamente enviar la suma de cinco numero consecutivos: UTILIZAR for +int main() + { + int contador2=0; + + while(1) + { + if (boton==1) + { + int x=x+1, y=x+4, suma=0; + if(x==1) + { + for(int contador=x;contador<=y;contador++) + { + suma=suma+contador; + } + comunication.printf("Resultado= %d\n", suma); + } + + else + { + int n=n+6, m=n+4; + for(int contador=n; contador<=m; contador++) + { + suma=suma+contador; + } + contador2++; + if(contador2>=2) + { + suma=suma-(5*(contador2-1)); + } + comunication.printf("%d\n", contador2); + comunication.printf("Respuesta: %d\n",suma); + } + } + +wait(1); +} +} \ No newline at end of file