Paso 5: El código
El compiladorUna de las principales ventajas de la plataforma mbed para es eso don´t usted necesita un compilador en su PC, there´s un compilador de 'nube' (en línea).
En primer lugar debe crear una cuenta en la Página Web de mbed para (http://mbed.org/ ) y luego tienes acceso al compilador en línea de la nube.
El código de
El código para este proyecto no es muy difícil, tal vez porque la plataforma mbed para tiene un montón de bibliotecas listos para funcionar.
#include "mbed.h"
Define los puertos de entrada/salida digital
DigitalOut led1(p16);
DigitalOut led2(p15);
DigitalOut led3(p14);
DigitalOut led4(p25);
DigitalOut led5(p26);
El mensaje del día de valentine´s Español (sustituirlo por su propio)
#define MATRIX_LENGTH 11
#define MESSAGE_LENGTH 65
UINT8 heart_matrix [5] [MATRIX_LENGTH] = {}
{0,0,1,1,0,0,0,1,1,0,0},
{0,1,1,1,1,0,1,1,1,1,0},
{0,0,1,1,1,1,1,1,1,0,0},
{0,0,0,0,1,1,1,0,0,0,0},
{0,0,0,0,0,1,0,0,0,0,0}
};
UINT8 message_matrix [5] [MESSAGE_LENGTH] = {}
{1,1,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,1,1,0,1,0,0,1,0,1,1,1,0,1,0,1,0,0,1,0},
{1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1,0,1,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1,1,0,1,0,0,1,0,0,1,0,1,1,0,1,0},
{1,1,1,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,0,1,0,1,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,1,1,1,0,1,0,1,1,0,0,1,0,0,1,0,1,0,1,1,0},
{1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,0,1,0,0,1,0,1,0,1,1,1,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0},
{1,0,0,0,1,1,1,0,1,1,1,0,1,0,1,1,1,0,0,1,1,1,0,1,0,1,0,1,0,0,1,0,0,0,1,0,0,1,0,1,0,1,1,1,0,1,1,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0}
};
int main()
{
unsigned char flag_start;
unsigned char cont;
imagen de unsigned char;
Estado de unsigned char;
cont = 0;
imagen = 0;
flag_start = 50;
estado = 0;
LED1 = 0;
LED2 = 0;
LED3 = 0;
LED4 = 0;
LED5 = 0;
while(1)
{
Switch(State)
{
caso 0:
Switch(Image)
{
caso 0:
LED1 = heart_matrix [0] [cont];
LED2 = heart_matrix [1] [cont];
LED3 = heart_matrix [2] [cont];
LED4 = heart_matrix [3] [cont];
LED5 = heart_matrix [4] [cont];
cont ++;
Si (cont > = MATRIX_LENGTH)
{
cont = 0;
imagen = 1; Cambiar a otra imagen
}
rotura;
caso 1:
LED1 = message_matrix [0] [cont];
LED2 = message_matrix [1] [cont];
LED3 = message_matrix [2] [cont];
LED4 = message_matrix [3] [cont];
LED5 = message_matrix [4] [cont];
cont ++;
Si (cont > = MESSAGE_LENGTH)
{
cont = 0;
imagen = 0; Cambiar a otra imagen
estado = 1;
}
rotura;
}
caso 1:
if(flag_start>0)
{
flag_start--;
}
if(flag_start==0)
{
flag_start = 80;
estado = 0;
}
rotura;
}
Espere 3 ms para cambiar el LED de encendido/apagado, este tiempo depende la más amplia la carta
wait_ms(3);
}
}