專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

XS128單片機(jī)實(shí)驗(yàn):讀取撥碼開關(guān)值

作者:韓冰   來源:本站原創(chuàng)   點(diǎn)擊數(shù):  更新時(shí)間:2013年11月30日   【字體:


#include <hidef.h>      /* common defines and macros */
#include "derivative.h"      /* derivative-specific definitions */
/*********************************************************
//功能: 讀取PORTA口撥碼開關(guān)狀態(tài),通過portb 口的LED燈顯示
//This is the third program of mine
//已通過硬件驗(yàn)證;
//Date:  2013/4/13
*********************************************************/
void main(void) {
   unsigned char sw_value;      //定義變量,記錄撥碼開關(guān)設(shè)置值
 
   DDRA = 0X00;                 //定義A口為輸入口
   DDRB = 0XFF;                 //定義B口為輸出口
   while(1){           
    sw_value = PORTA;
    PORTB    = sw_value;
   }
}
 

關(guān)閉窗口

相關(guān)文章