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
- Committer:
- akumagame
- Date:
- 2020-04-28
- Revision:
- 4:e4c22c0ec2c2
- Parent:
- 3:5c5fdb28cdc0
- Child:
- 5:597a85f2a7c0
File content as of revision 4:e4c22c0ec2c2:
#include "mbed.h"
#include <stdio.h>
#include <stdlib.h> //incluye srand() y rand()
#include <time.h> //incluye time()
Serial com1(USBTX, USBRX);
char mat[5][5]; //tamaño de la matriz
char letras[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int numdeletras=sizeof(letras)/sizeof(letras[0])-1;
DigitalOut Ledrojo(PTB22);
DigitalOut Ledazul(PTB21);
DigitalOut Ledverde(PTE26);
InterruptIn bot(PTA4);
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
com1.printf("|\t%c|",mat[i][j]);//imprime elemento de la matriz en pantalla
}
com1.printf("\n_______________\n");//para dejar espacios entre filas.
}
getchar();
if (mat[2][2] >= 'a' && mat[2][2] <= 'z'){
com1.printf("La letra en la posicion 2,2 es minuscula\n \n \n \n");
Ledrojo=0;
Ledazul=1;
Ledverde=1;
}
else{
com1.printf("La letra en la posicion 2,2 es mayuscula\n \n \n \n ");
Ledazul=1;
Ledrojo=1;
Ledverde=0;
}
}
int main()
{
com1.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(&funcion);
while(1){
funcion();
wait(60);
}
}