微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 读取8421拨码开关的值~~~

读取8421拨码开关的值~~~

时间:10-02 整理:3721RD 点击:
请问怎么读取8421拨码开关的值呀,
假设3个拨码开关,公共端都接了地,
百,十,个,分别P0的8个口和P1的4个口,
我下面的程序有错吗?
void time_1(uint time_1)
        {
        unsigned char bai,shi,ge,temp;
        unsigned int time1;
        temp=P0;
        bai=temp&0x0f;
        shi=temp&0xf0;
        temp=P1;
        ge=temp&0x0f;
        time_1=bai*100+shi*10+ge;
        }
请高人指点。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top