点亮小灯之代码

点此查看电路分析

//点亮单个小灯

#include <reg52.h>

sbit P0_0 = P0 ^ 0;
sbit P1_0 = P1 ^ 0;
sbit P1_1 = P1 ^ 1;
sbit P1_2 = P1 ^ 2;
sbit P1_3 = P1 ^ 3;
sbit P1_4 = P1 ^ 4;

int main(void)
{
	P0_0 = 0;
	P1_0 = 0;
	P1_1 = 1;
	P1_2 = 1;
	P1_3 = 1;
	P1_4 = 0;

	while(1)
		;
}
//点亮单个小灯
#include <reg52.h>

sbit ADDR0 = P1 ^ 0;
sbit ADDR1 = P1 ^ 1;
sbit ADDR2 = P1 ^ 2;
sbit ADDR3 = P1 ^ 3;

sbit ENLED = P1 ^ 4;


int main(void)
{
    ENLED = 0; 
    ADDR3 = 1; 
    
    ADDR2 = 1; 
    ADDR1 = 1; 
    ADDR0 = 0; 
    
    P0 = 0xFE;
    while (1)
        ;
}

 

posted @ 2024-10-01 11:49  EricsT  阅读(26)  评论(0编辑  收藏  举报