6CM8 / Mbed 2 deprecated STM32F103C8_Teclado

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "stm32f103c8t6.h"
00002 #include "mbed.h"
00003 
00004 BusOut      display(PB_4,PB_3,PA_15,PA_12,PA_11,PA_10,PA_9,PA_8);
00005 BusOut      multiplexaje(PA_3,PA_2,PA_1,PA_0);
00006 BusIn       entrada(PB_0,PB_1,PB_10,PB_11);
00007 BusOut      salida(PB_6,PB_7,PB_8,PB_9);
00008 
00009 
00010 uint8_t Numero[4][4]=
00011 {
00012     {0x42,0xB6,0xBC,0xFA},
00013     {0xD8,0xEC,0xEE,0xCE},
00014     {0x38,0xFE,0xFC,0x86},
00015     {0x80,0x7E,0xFA,0x9E}    
00016 };
00017 
00018 uint8_t catodo[]=
00019 {
00020     //0b0001,0b0010,0b0100,0b1000
00021     0x01,0x02,0x04,0x08
00022 };
00023 
00024 uint8_t fila[]=
00025 {
00026     0x01,0x02,0x04,0x08
00027 };   
00028 
00029 uint8_t columna[]=
00030 {
00031     //0b0001,0b0010,0b0100,0b1000
00032     0x01,0x02,0x04,0x08
00033 };  
00034       
00035 void Encender(int C,int F);
00036     
00037 int main() 
00038 {
00039     
00040     while(1) 
00041     {                      
00042         for(int i=0; i<4; i++)
00043         {
00044             salida=columna[i];
00045             
00046             if(entrada!=0)
00047             {
00048                 if(entrada==fila[0])
00049                 {
00050                     Encender(i,0);                   
00051                 }else if(entrada==fila[1])
00052                     {
00053                         Encender(i,1);
00054                     }else if(entrada==fila[2])
00055                         {
00056                             Encender(i,2);
00057                         }else if(entrada==fila[3])
00058                             {
00059                                 Encender(i,3);
00060                             }
00061             }
00062         }    
00063     }
00064 }
00065 
00066 
00067 void Encender(int C,int F)
00068 {
00069     multiplexaje=catodo[0];
00070    
00071     display=Numero[F][C];          
00072     wait_ms(200);
00073     
00074     multiplexaje=0x00;
00075     display=0x00;
00076 }