• Tin mới

    [PIC TUTORIAL] BÀI 14 PortD=0 thì xuất PortC=0xff ngược lại xuất PortC=0x0f

    SƠ ĐỒ MẠCH ĐIỆN



    CHƯƠNG TRÌNH MẪU

    #include "16f887.h"
    #include "def_16f887.h"
    #fuses  NOWDT,NOPROTECT,PUT,NOLVP,XT 
    #use    delay(clock = 4000000)         //Tan so thach anh 4MHz
    
    void main()
    {
       setup_adc_ports(NO_ANALOGS|VSS_VDD);
       setup_adc(ADC_OFF);
       setup_spi(SPI_SS_DISABLED);
       setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
       setup_timer_1(T1_DISABLED);
       setup_timer_2(T2_DISABLED,0,1);
       setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
    //Setup_Oscillator parameter not selected from Intr Oscillotar Config tab
    
       set_tris_c(0x00);    //PORTC xuat du lieu.
       set_tris_d(0xff);    //PORTD nhap du lieu.
       while(1)
       {
          if(PORTD == 0)
             PORTC = 0xff;
          else
             PORTC = 0x0f;
          delay_ms(20);
       }
    }
    




    DOWNLOAD FILE MÔ PHỎNG + CODE
    (Bấm vào link đợi 5s, sau đó bấm "Skip Ad" sẽ ra link download) 



    No comments