Jair Valdovinos / Mbed 2 deprecated PARCIAL

Dependencies:   mbed FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"  
00002 
00003 InterruptIn boton(p5);
00004 Timer tiempoA;
00005 Ticker Solo;
00006 
00007 DigitalIn boton1(p5);
00008 DigitalOut led [4][4]=
00009 {
00010     DigitalOut (p6), DigitalOut (p7), DigitalOut (p8),DigitalOut (p9),
00011     DigitalOut (p10),DigitalOut (p11),DigitalOut (p12),DigitalOut (p13),
00012     DigitalOut (p14),DigitalOut (p15),DigitalOut (p16),DigitalOut (p17),
00013     DigitalOut (p18),DigitalOut (p19),DigitalOut (p20),DigitalOut (p21),
00014 };
00015 
00016 Serial com1(USBTX, USBRX);
00017 
00018 void matriz(void)
00019 {
00020     int ceros=0;
00021     com1.printf("**\n");
00022     srand(time(NULL ));
00023     int matriz [4][4];
00024     srand(time(0));
00025     for (int fila = 0; fila < 4; fila++)
00026     {
00027         for (int columna = 0; columna < 4; columna++)
00028         {                       // 0,1
00029             if(ceros<8)
00030             {
00031                 led[fila][columna]=matriz[fila][columna] = rand() % 2; //0
00032                 com1.printf(" %d",matriz[fila][columna]);
00033                 if(matriz[fila][columna] == 0)
00034                 {
00035                     ceros=ceros+1;
00036                 }
00037             }
00038             else
00039             {
00040                 led[fila][columna]=matriz[fila][columna] = 1;
00041                 com1.printf(" %d",matriz[fila][columna]);
00042             }
00043         }
00044         com1.printf("\n");
00045     }
00046     com1.printf("\n");
00047 }
00048 
00049  int main()
00050  {
00051     tiempoA.start();
00052     boton.rise(matriz);
00053     Solo.attach(matriz, 60);
00054     while(true) 
00055     {
00056         wait(1);
00057         
00058     }
00059  }