ตัวอย่าง PIC C Compiler


OUTPUT

/$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//Code Support     : Board Trainning               $
//Compiler         : PIC C Compiler Version 3.207  $
//Micro Controller : PIC16F877A                    $
//OSC              : 10MHz                         $
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

#include <16F877A.h>

#fuses  HS,NOLVP,NOWDT,NOPROTECT
#use    delay (clock = 10000000)    // Crytal = 10MHz

#use    fast_io(B)

//****************************************************
void main()
{
   //-------------------------------------------------
      set_tris_b(0x00);       // 0000 0000
   //-------------------------------------------------

   while(true)
   {
      output_b(0x00);  // PortB = 0000 0000
      delay_ms(200);   // Delay 200ms

      output_b(0xFF);  // PortB = 1111 1111
      delay_ms(200);   // Delay 200ms
   }

}



INPUT

//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//Code Support     : Board Trainning               $
//Compiler         : PIC C Compiler Version 3.245  $
//Micro Controller : PIC16F877                     $
//OSC              : 10MHz                         $
//         WWW.MECHATRONICS-LAB.COM                $
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

#include <16F877.h>

#fuses  HS,NOLVP,NOWDT,NOPROTECT
#use    delay (clock = 10000000)    // Crytal = 10MHz

#use    fast_io(B)
#use    fast_io(D)

//----------------------------------------------------
int8 a;
//----------------------------------------------------
//****************************************************************************
void main()
{
   //-------------------------------------------------
   set_tris_b(0xFF);    // 1111 1111    PortB is Input
   set_tris_d(0x00);    // 0000 0000    PortD is Output
   port_b_pullups(true);
   //-------------------------------------------------

   while (TRUE)
   {
      a = input_b();
      output_d(a);

   }
}
//****************************************************************************





ไม่มีความคิดเห็น:

แสดงความคิดเห็น