programa para controlar un display de 7 segmentos con tres botoners, incremento, decremento y seteo a cero
main.cpp
00001 #include "mbed.h" 00002 #include "stdio.h" 00003 //Declaracion de Puertos 00004 BusIn ent(PB_12,PB_13,PB_14); 00005 PortOut OutA(PortA,0x00FF); 00006 //Declaracion de Variables 00007 short display[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; 00008 unsigned char cont=0; 00009 00010 int main(){ 00011 while(1){ 00012 OutA=display[cont]; 00013 switch(ent){ 00014 case (0x1): //funcion incrementar 00015 cont ++; 00016 if (cont == 10) 00017 cont = 0; 00018 wait_ms(200); 00019 break; 00020 case (0x2): //funcion decrementar 00021 cont --; 00022 if (cont == 0xff) 00023 cont = 9; 00024 wait_ms(200); 00025 break; 00026 case (0x4): //funcion setear 00027 cont = 0; 00028 break; 00029 default: OutA=display[cont]; 00030 break; 00031 } 00032 } 00033 }
Generated on Thu Oct 6 2022 16:11:14 by
1.7.2