标题: 如何用keil和proteus点亮流水灯 求帮助 [打印本页]

作者: 哈哈HH    时间: 2018-1-22 14:48
标题: 如何用keil和proteus点亮流水灯 求帮助
代码:
  1. #include<reg52.h>
  2. #define uint unsigned int
  3. #define uchar unsigned char
  4. uchar temp[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff};
  5. void delay(uint z)
  6. {
  7. uint x,y;
  8. for(x=100;x>0;x--)
  9.   for(y=z;y>0;y--);
  10. }
  11. void main()
  12. {
  13. uchar i;
  14.   while(1)
  15. {
  16.    for(i=0;i<9;i++)     
  17. {
  18.    P0=temp[i];
  19.    delay(400);
  20. }
  21.    for(i=0;i<9;i++)
  22. {
  23.   P1=temp[i];
  24.    delay(400);
  25. }
  26. }
  27. }
复制代码

proteus中电路图
[img][/img]
点亮流水灯有4种方法
1、最基础的方法,分条列举出来
2、先左移,后或
3、调用左移函数_crol_()
4、使用数组{0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1