Basic I/O port operations

Publisher:恬淡岁月Latest update time:2016-11-04 Source: eefocusKeywords:I Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
//Use of MCU I/O port

//★★★★★★★★★Use of MCU I/O port★★★★★★★★★★★\\
//MCU model: PIC16F877A
//Function description: Make the RC0 port light flash

#include //Includes the internal resources of the MCU predefined
__CONFIG(0XF73A); //Chip configuration word
 void delay(); //delay function declaration


//==============================================================================
//Function: main function
//Function name: void main()
void main() //Main function
  {
    TRISC=0X00; //Port C is defined as outputwhile
  (1) //Infinite loop, let the port C running light work all the time
    {
    PORTC=0X01; //Let the RC0 port light flash on and off
     delay(); //Delay, ensure brightness and time so that the naked eye can see the phenomenon
    PORTC=0X00;
     delay();
    }
  }


//=================================================================================
//Function function: delay function
//Function name: void delay()  
void delay() //Delay subroutine
  {
    int i; //Define integer variable
  for(i=0x65535;i>0;i--)     
    {;} //Empty function, does not execute anything, just consumes a certain amount of time
  }

Keywords:I Reference address:Basic I/O port operations

Previous article:Use of LCD1602A
Next article:Basic I/O port operations

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号