Reloj Digital

Páginas: 6 (1306 palabras) Publicado: 9 de mayo de 2015
REPÚBLICA BOLIVARIANA DE VENEZUELA
MINISTERIO DEL PODER POPULAR PARA LA DEFENSA
UNIVERSIDAD NACIONAL EXPERIMENTAL DE LA FUERZA ARMADA
UNEFA
INGENIERÍA DE SISTEMAS





Reloj Digital




INTEGRANTES:
Maryoly Montilla C.i 21256556
Esperanza Pereira C.I 26.523807Sección: 06 ITTCD01
Prof: José Muñoz

Caracas, 15 de noviembre de 2014
Código en Pic C compiler:
#include <18F4550.h>
#device ADC=8
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48M)
#include
#include
#byte PUERTOA=0xf80
#byte PUERTOB=0xf81
#byte PUERTOC=0xf82#byte PUERTOD=0xf83
#byte PUERTOE=0xf84
#byte PIR1=0xf9E //maneja tmr0, tmr1, tmr2,tmr3
#bit TMR1IF = PIR1.0 /*DEFINE LA BANDERA DE SOBREPASO DE TIMER1*/
#bit TMR2IF = PIR1.1
int seg=38;
int min=43;
int hor=12;
int1 bandera=1;
char msj[16]="RELOJ DIGITAL";
int i,sw=1,t=0,ampm=1,auxb=0;
void pantalla();
void inicio();
void chequeo();
void presentacion();
void nombre();

void Tiempo()
{bit_clear (PIR1,0 ); /*LIMPIA LA BANDERA DE SOBREPASO*/
set_TIMER1(15286); /*INICIALIZA EL TIMER PARA T=402mseg*/
while (!TMR1IF); //cuenta el tiempo de 402mseg

}
void main()
{
lcd_init();
while(TRUE)
{
if(bandera==1)
{
printf(lcd_putc,"\f.PROY:3RELOJ DIG.");
lcd_gotoxy(2,2);
}
Setup_adc_ports(NO_ANALOGS);
lcd_init();
set_tris_a(0b00000001);
set_tris_a(0b11111110);set_tris_b(0b11111111);
set_tris_C(0b00000000);
set_tris_d(0b00000000);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
PUERTOB=0XFF;
PUERTOA=0XFF;
while (TRUE)
{
switch(sw)
{
case 1:
lcd_gotoxy(14,3);
if(ampm==1)
{
set_tris_a(0b00000001);
printf(lcd_putc,"\f AM")
}
else
{set_tris_a(0b11111110);
printf(lcd_putc,"\f PM");
}
lcd_gotoxy(5,3);
if(hor<10)
{
printf(lcd_putc,"0");
}
printf(lcd_putc,"%d",hor);
lcd_gotoxy(7,3);
printf(lcd_putc,"%s",":");
lcd_gotoxy(8,3);
if(min<10)
{
printf(lcd_putc,"0");
}
printf(lcd_putc,"%d",min);
lcd_gotoxy(10,3);
printf(lcd_putc,"%s",":");
lcd_gotoxy(11,3);
if (seg<10)
{
printf(lcd_putc,"0");
}printf(lcd_putc,"%d",seg);
for (i=0;i<2;i++)
{
t++;
Tiempo();
if(t>24)
{
t=0;
seg++;
}
}
seg++;

if (seg>59)
{
seg=0;
printf(lcd_putc,"\f");
min++;
}
if(min>59)
{
min=0;
hor++;
}
if(hor>12){hor=1; auxb=0;}
if (!input(PIN_B0))
{
sw=2;
printf(lcd_putc,"\f");
output_bit(PIN_A0,0);
while(!input(PIN_B0));
}if(hor>11&& auxb==0)
{
if(ampm==1)
{
ampm=1;
output_bit(PIN_A1,1);
output_bit(PIN_A2,0);
lcd_gotoxy(13,3);
printf(lcd_putc,"AM");
}
else
{
ampm=0;
output_bit(PIN_A1,0);
output_bit(PIN_A2,1);
lcd_gotoxy(13,3);
printf(lcd_putc,"PM");
}
auxb=1;
}
break;



case 2:
if(!input(PIN_B0))
{
hor++;
if(hor>12)
{
hor=1;
}while(!input(PIN_B0));
}
if(!input(PIN_B1))
{
min++;
if(min>59)
{
min=0;
}
while(!input(PIN_B1));
}
if(!input(PIN_B2));
{
seg++;
if(seg>59)
{
seg=0;
}
while(!input(PIN_B2));
}
lcd_gotoxy(5,3);
if(hor<10)
{
printf(lcd_putc,"0");
}
printf(lcd_putc,"%d",hor);
printf(lcd_putc,":");
if(min<10)
{
printf(lcd_putc,"0");
}printf(lcd_putc,"%d",min);
printf(lcd_putc,":");

if(seg<10)
{
printf(lcd_putc,"0");
}
printf(lcd_putc,"%d",seg);
if (!input(PIN_B2))
{
sw=1;
printf(lcd_putc,"\f");
output_bit(PIN_A0,0);
while(!input(PIN_B2));
}
if (!input(PIN_B3)){
if(ampm==1)
{
ampm=0;
output_high(PIN_A0);
lcd_gotoxy(13,3);
printf(lcd_putc,"PM");
}
else
{...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Reloj digital
  • Reloj Digital
  • Reloj Digital
  • Reloj Digital
  • Reloj digital
  • reloj digital
  • Reloj Digital
  • Reloj Digital

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS