新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > XS128單片機實驗:讀取撥碼開關(guān)值

XS128單片機實驗:讀取撥碼開關(guān)值

作者: 時間:2016-12-01 來源:網(wǎng)絡(luò) 收藏
#include /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
/*********************************************************
//功能: 讀取PORTA口撥碼開關(guān)狀態(tài),通過portb 口的LED燈顯示
//This is the thirdprogramof mine
//已通過硬件驗證;
//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;
}
}


評論


技術(shù)專區(qū)

關(guān)閉