找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4867|回复: 0
打印 上一主题 下一主题
收起左侧

STM32单片机独立按键控制跑马灯的明亮

[复制链接]
跳转到指定楼层
楼主
通过单片机控制跑马灯的明亮


STM32源程序如下:
  1. //相关头文件包含
  2. #include "delay.h"
  3. #include "sys.h"
  4. #include "led.h"
  5. #include "key.h"

  6. int main(void)
  7. {       
  8.         delay_init();       
  9.   LED_Init();
  10.   Key_GPIO_Config();       
  11.         while(1)
  12.         {        
  13.                 if(Key_Scan(GPIOC,GPIO_Pin_0)==0)
  14.                 {
  15.                   GPIO_SetBits(GPIOC,GPIO_Pin_2);
  16.                         delay_ms (300);
  17.                         GPIO_ResetBits(GPIOC,GPIO_Pin_2);
  18.                   GPIO_SetBits(GPIOC,GPIO_Pin_3);
  19.                         delay_ms (300);
  20.                         GPIO_ResetBits(GPIOC,GPIO_Pin_3);
  21.                          GPIO_SetBits(GPIOC,GPIO_Pin_4);
  22.                         delay_ms (300);
  23.                         GPIO_ResetBits(GPIOC,GPIO_Pin_4);
  24.                          GPIO_SetBits(GPIOC,GPIO_Pin_5);
  25.                         delay_ms (300);
  26.                         GPIO_ResetBits(GPIOC,GPIO_Pin_5);
  27.                          GPIO_SetBits(GPIOC,GPIO_Pin_6);
  28.                         delay_ms (300);
  29.                         GPIO_ResetBits(GPIOC,GPIO_Pin_6);
  30. ……………………

  31. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
独立按键.zip (344.15 KB, 下载次数: 32)


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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