Ir ao conteúdo
  • Cadastre-se

joseca

Membro Pleno
  • Posts

    161
  • Cadastrado em

  • Última visita

Tópicos solucionados

  1. O post de joseca em Rotina com if,else foi marcado como solução   
    tirei o while(true)
    tirei as chaves para sair desse loop,deixei somente as duas
    mas não roda a parte debaixo,o que esta ocorrendo?
    Obrigado pelos retornos
    Resolvido o problema,eram as chaves mesmo,veja como ficou
    #include <16f877a.h>
    #fuses HS,NOWDT,NOPROTECT,NOLVP
    #use delay (clock=20000000)
    void main(){
    while(true){
    if((input(pin_a0))==1)
    output_high(pin_b0);
    else
    output_low(pin_b0);
    if((input(pin_a1))==1)
    output_high(pin_b1);
    else
    output_low(pin_b1);
    if((input(pin_a2))==1)
    output_high(pin_b2);
    else
    output_low(pin_b2);
    }
    }
    Obrigado Isadora pelas dicas,codigo rodando muito bem!
    Moderador poder fechar o topico
  2. O post de joseca em Projeto de relógio com termômetro (lm35) com PIC16F877A foi marcado como solução   
    Fiz algumas modificações no codigo do vtrx,para tocar um bip nas horas cheias e acender o back light
    #include <16F877A.h>#device adc=10 //Habilitar ADC de 10 bits, obrigatório. Pode //ser utilizado de 8 bits também.#FUSES NOWDT //No Watch Dog Timer#FUSES XT //Clock <=4Mhz#FUSES PUT //Power Up Timer#FUSES NOPROTECT //Code not protected from reading#FUSES NOBROWNOUT //No brownout reset#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O#FUSES NOCPD //No EE protection#use delay(clock=4000000)#include <ds1307.c>#include <lcd.c>#define botao_incremento PIN_B0#define botao_decremento PIN_B1BYTE sec;BYTE min;BYTE hrs;BYTE day;BYTE month;BYTE yr;BYTE dow;int8 modo,temp;int16 adc;float temperatura;char dia_da_semana[7][8]={ "DOMINGO", "SEGUNDA", "TERCA", "QUARTA", "QUINTA", "SEXTA", "SABADO",};#int_ccp2void trata_ccp_2(){ modo++; if (modo > 7 ) { modo = 0; }}void main(){ setup_ccp2(CCP_CAPTURE_RE); enable_interrupts (int_ccp2); enable_interrupts (global); setup_adc_ports(AN0); //Configura canal 0 analógico setup_adc(ADC_CLOCK_INTERNAL); //De acordo com relógio interno. set_adc_channel(0); //Habilita canal 0 delay_us(20); //Espera um pouco, obrigatório! ds1307_init(); lcd_init(); modo = 0; temp=0; while(true) { switch (modo) { case 1: { if (input(BOTAO_INCREMENTO)) { delay_ms (75); hrs++; } if (input(BOTAO_DECREMENTO)) { delay_ms (75); hrs--; } if (hrs > 23 ) { hrs = 0; } /*if (hrs == 255 ) { hrs = 23; }*/ printf(lcd_putc,"\fAjustar Hora:\n%u",hrs); delay_ms (100); break; } case 2: { if (input(BOTAO_INCREMENTO)) { delay_ms (75); min++; } if (input(BOTAO_DECREMENTO)) { delay_ms (75); min--; } if (min > 59 ) { min = 0; } /*if (min == 255 ) { min = 59; }*/ printf(lcd_putc,"\fAjustar Minutos:\n%u",min); delay_ms (100); break; } case 3: { if (input(BOTAO_INCREMENTO)) { delay_ms (75); sec++; } if (input(BOTAO_DECREMENTO)) { delay_ms (75); sec--; } if (sec > 59 ) { sec = 0; } /*if (sec == 255 ) { sec = 59; }*/ printf(lcd_putc,"\fAjustar Segundos:\n%u",sec); delay_ms (100); break; } case 4: { if (input(BOTAO_INCREMENTO)) { delay_ms (75); day++; } if (input(BOTAO_DECREMENTO)) { delay_ms (75); day--; } if (day > 31 ) { day = 1; } if (day == 0 ) { day = 31; } printf(lcd_putc,"\fDia do Mes:\n%u",day); delay_ms (100); break; } case 5: { if (input(BOTAO_INCREMENTO)) { delay_ms (75); month++; } if (input(BOTAO_DECREMENTO)) { delay_ms (75); month--; } if (month > 12 ) { month = 1; } if (month == 0 ) { month = 12; } printf(lcd_putc,"\fAjustar Mes:\n%u",month); delay_ms (100); break; } case 6: { if (input(BOTAO_INCREMENTO)) { delay_ms (75); yr++; } if (input(BOTAO_DECREMENTO)) { delay_ms (75); yr--; } if (yr > 99 ) { yr = 1; } if (yr == 0 ) { yr = 99; } printf(lcd_putc,"\fAjustar Ano:\n%u",yr); delay_ms (100); break; } case 7: { if (input(BOTAO_INCREMENTO)) { delay_ms (75); dow++; } if (input(BOTAO_DECREMENTO)) { delay_ms (75); dow--; } if (dow > 7 ) { dow = 1; } if (dow == 0) { dow = 7; } printf(lcd_putc,"\fDia da Semana:\n%s",dia_da_semana[dow-1]); delay_ms (100); ds1307_set_date_time(day,month,yr,dow,hrs,min,sec); break; } default: { if ((min == 59) && (sec ==59)){ output_high(pin_b4); delay_ms(100); output_low(pin_b4); delay_ms(100); output_high(pin_b4); delay_ms(100); output_low(pin_b4); } { temp++; if(temp == 10){ adc = read_adc(); //Lê canal 0 temperatura = (5.0 * adc * 100) / 1024.0; //Conversão para tensão. temp=0; } ds1307_get_date(day,month,yr,dow); ds1307_get_time(hrs,min,sec); printf(lcd_putc,"\f%s %02d:\%02d:\%02d\n%02d/\%02d/\%02d %2.0f%cC",dia_da_semana[dow-1],hrs,min,sec,day,month,yr,temperatura,0xdf); // printf(lcd_putc,"\f%s %02d:\%02d:\%02d\n%02d/\%02d/\%02d %f",dia_da_semana[dow-1],hrs,min,sec,day,month,yr,temperatura); delay_ms(100); { output_high (PIN_B5); } // output_toggle(pin_b2);{ // delay_ms(100); // output_toggle(pin_b3); // delay_ms(500); // output_toggle(pin_b3); // delay_ms(500); } } } } }

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!