登录  | 立即注册

游客您好!登录后享受更多精彩

扫一扫,访问微社区

QQ登录

只需一步,快速开始

开启左侧

[寒假笔记] C51单片机 LED流水灯

[复制链接]
发表于 2023-1-30 14:36:25 | 显示全部楼层 |阅读模式
学习笔记
学习科目: 51单片机
学习安排: 想学再学
开始时间: 2023-01-14
结束时间:
本帖最后由 马新豪 于 2023-1-30 14:36 编辑
  1. #include <STC12C5AXX.h>
  2. void Delay500ms()                //@32.000MHz
  3. {
  4.         unsigned char i, j, k;

  5.         i = 61;
  6.         j = 204;
  7.         k = 243;
  8.         do
  9.         {
  10.                 do
  11.                 {
  12.                         while (--k);
  13.                 } while (--j);
  14.         } while (--i);
  15. }


  16. void main ()
  17. {
  18.         while(1)
  19.         {
  20.                 P11=0;
  21.                 P20=0;
  22.                 P21=1;
  23.                 P22=1;
  24.                
  25.                 P00=0;
  26.                 Delay500ms();
  27.                 P00=1;
  28.                 Delay500ms();
  29.                 P01=0;
  30.                 Delay500ms();
  31.                 P01=1;
  32.                 Delay500ms();               
  33.                 P02=0;
  34.                 Delay500ms();
  35.                 P02=1;
  36.                 Delay500ms();               
  37.                 P03=0;
  38.                 Delay500ms();      
  39.                 P03=1;
  40.                 Delay500ms();
  41.                 P04=0;
  42.                 Delay500ms();      
  43.                 P04=1;
  44.                 Delay500ms();
  45.                 P05=0;
  46.                 Delay500ms();      
  47.                 P05=1;
  48.                 Delay500ms();
  49.                 P06=0;
  50.                 Delay500ms();      
  51.                 P06=1;
  52.                 Delay500ms();
  53.                 P07=0;
  54.                 Delay500ms();      
  55.                 P07=1;
  56.                 Delay500ms();               
  57.         }
  58. }
复制代码
效果图:

LED RUNNING.gif
好懒~~不想说~~~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表