P0口要接上拉电阻 |
本帖最后由 dy212300 于 2019-12-17 16:09 编辑 是P0=b |
烧的以前的程序?? |
本帖最后由 wulin 于 2019-12-17 10:16 编辑 新人求指导啊1 发表于 2019-12-16 17:15 程序基本可行,但写得有点啰嗦,甚至不合理。仿真异常是图画错,必须要在LED串接300Ω~1K左右限流电阻,否则实际电路IO口有烧毁的风险。程序可以简化为:
|
crol是循环左移,延时太短,程序中再加3个delay(250);试试 |
程序如下: #include <reg51.h> #include <stdio.h> #include <intrins.h> sbit P0_0 = P0^0; sbit P0_1 = P0^1; sbit P0_2 = P0^2; sbit P0_3 = P0^3; sbit P0_4 = P0^4; sbit P0_5 = P0^5; sbit P0_6 = P0^6; sbit P0_7 = P0^7; void delay(unsigned char a) { unsigned char i; while(--a!=0) { for(i=0;i<125;i++); } } void main(void) { unsigned char b; unsigned char i; while(1) { b=0x7f; for(i=0;i<8;i++) { P0=_crol_(b,1); b=P0; delay(250); } } } |