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:e091e85bb254
- Child:
- 1:a103588e2d87
diff -r 000000000000 -r e091e85bb254 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Apr 28 01:33:06 2020 +0000
@@ -0,0 +1,75 @@
+#include "mbed.h"
+#include <stdio.h>
+#include <stdlib.h> //incluye srand() y rand()
+#include <time.h> //incluye time()
+
+char mat[5][5]; //tamaño de la matriz
+char letras[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+int numdeletras=sizeof(letras)/sizeof(letras[0])-1;
+DigitalOut Ledrojo(p5);
+DigitalOut Ledazul(p6);
+InterruptIn bot(p10);
+void funcion ();
+
+void funcion(void){
+ for (int i=0;i<5;i++)//para desplazarse por las columnas
+ {
+ for (int j=0;j<5;j++)//para desplazarse por las filas
+ {
+ mat[i][j]=letras[rand()%numdeletras];//Agrega numero aleatorio a la posicion ij de la matriz
+ printf("|\t%c|",mat[i][j]);//imprime elemento de la matriz en pantalla
+ }
+ printf("\n___________________________________________\n");//para dejar espacios entre filas.
+ }
+ getchar();
+ if (mat[2][2] >= 'a' && mat[2][2] <= 'z'){
+ printf("La letra en la posicion 2,2 es minuscula\n \n \n \n");
+ Ledrojo=1;
+ Ledazul=0;
+ }
+ else{
+ printf("La letra en la posicion 2,2 es mayuscula\n \n \n \n ");
+ Ledazul=1;
+ Ledazul=0;
+ }
+}
+
+void fun(void){
+ for (int i=0;i<5;i++)//para desplazarse por las columnas
+ {
+ for (int j=0;j<5;j++)//para desplazarse por las filas
+ {
+ mat[i][j]=letras[rand()%numdeletras];//Agrega numero aleatorio a la posicion ij de la matriz
+ printf("|\t%c|",mat[i][j]);//imprime elemento de la matriz en pantalla
+ }
+ printf("\n___________________________________________\n");//para dejar espacios entre filas.
+ }
+ getchar();
+ if (mat[2][2] >= 'a' && mat[2][2] <= 'z'){
+ printf("La letra en la posicion 2,2 es minuscula\n \n \n \n");
+ Ledrojo=1;
+ Ledazul=0;
+ }
+ else{
+ printf("La letra en la posicion 2,2 es mayuscula\n \n \n \n ");
+ Ledazul=1;
+ Ledazul=0;
+ }
+}
+
+
+
+int main()
+{
+ printf("Este programa genera una matriz de 5x5 \n con letras de manera aleatoria, \n determina en la posicion 2,2 si es una \n letra mayuscula encendiendo un led\n azul o minuscula encendiendo \n un led rojo. Presioando el boton vuelve a \n generar otra matriz el programa\n y cada 60 segundos se reinicia.\n \n \n \n \n");
+
+bot.rise(*fun);
+
+ while(1){
+
+ funcion();
+
+ wait(20);
+
+ }
+}
\ No newline at end of file