標(biāo)題: 如何用keil和proteus點(diǎn)亮流水燈 求幫助 [打印本頁(yè)]

作者: 哈哈HH    時(shí)間: 2018-1-22 14:48
標(biāo)題: 如何用keil和proteus點(diǎn)亮流水燈 求幫助
代碼:
  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. }
復(fù)制代碼

proteus中電路圖
[img][/img]
點(diǎn)亮流水燈有4種方法
1、最基礎(chǔ)的方法,分條列舉出來(lái)
2、先左移,后或
3、調(diào)用左移函數(shù)_crol_()
4、使用數(shù)組{0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1