• Tin mới

    [PIC TUTORIAL] BÀI 12 Led sáng dần từ Led thứ 0 đến Led thứ 7, thời gian sáng là 1s

    SƠ ĐỒ MẠCH ĐIỆN




    CHƯƠNG TRÌNH MẪU

    #include "16f887.h"
    #include "def_16f887.h"
    #fuses  NOWDT,NOPROTECT,PUT,NOLVP,HS 
    #use    delay(clock = 4000000)         //Tan so thach anh 4MHz
    int8 k;
    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.
    PORTC = 0x00;           //Cac led deu tat.
       while(1)    
       {
         delay_ms(1000);           //Delay nhin thay cac led deu tat.
         PORTC = (PORTC<<1)|0x01;  //Led sang dan.
         if(PORTC == 0xff)
         {
            delay_ms(1000);        //Delay nhin thay cac led deu sang.
            PORTC = 0x00;
         }
       }
    }
    


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



    2 comments:

    1. PORTC = (PORTC<<1)|0x01; ở dòng lệnh này cái |0,01 là sao vậy ạ ?

      ReplyDelete
    2. PORTC = (PORTC<<1)|0x01; ở dòng lệnh này cái |0,01 là sao vậy ạ ?

      ReplyDelete