LED_8

 /*

功能:8个LED,轮流显示1-2-3-4-5------F,然后一轮回来之后,再次显示1-2-3-4------F

时间:2011-9-30

作者:cos_sin_tan

*/

#include<stdio.h>
#include<reg52.h>
char pianxuan_num[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//相当于片选信号呢


char xianshi[]={
0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,//0--7
 0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e// 8--F               
};
//共阳极编码

/*
单片机LED共阳极段码表【0-F】

DB          0c0H,0f9H,0a4H,0b0H,99H,92H,82H,0f8H             [0-7]
DB          80H,90H,88H,83H,0c6H,0a1H,86H,8eH                 [8-F]
*/


/*
3f,06,5b,4f (0-3)
66,6d,7d,07 (4-7)
7f,6f,77,7c (8-A)
39,5e,79,71 (b-f)
单片机LED共阴极段码表【0-F】

DB         3FH,06H,5BH,4FH,66H,6DH,7DH,07H                      [0-7]
DB         7FH,6FH ,77H,7CH,39H,5EH,79H,71H,76H              [8-F]

*/
void delay(int count)
{
 int y = 45555;
 for(;count >0 ;count --)
  for(;y > 0 ;y--)
   ;
}
void main(void )
{
 int num = 0;
 int i=0 ;
 while(1)
 {
  for( ;i <16;i++)
  {
   P0 = xianshi[i];
   P2 = pianxuan_num[i%8];
   delay(4444);
   delay(4444);
   delay(4444);
   if(i == 15)
    i = -1; //注意这个呢,嘿嘿

   }
 }
}

/** * @file drv_bsp.h * @author yssickjgd (1345578933@qq.com) * @brief A板的板级支持包 * @version 0.1 * @date 2022-08-02 * * @copyright USTC-RoboWalker (c) 2022 * */ #ifndef DRV_BSP_H #define DRV_BSP_H /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal.h" /* Exported macros -----------------------------------------------------------*/ //初始化DC24被按位或的参数 #define BSP_DC24_LU_ON (1 << 0) #define BSP_DC24_LD_ON (1 << 1) #define BSP_DC24_RU_ON (1 << 2) #define BSP_DC24_RD_ON (1 << 3) //初始化颜色LED被按位或的参数 #define BSP_LED_R_ON (1 << 4) #define BSP_LED_G_ON (1 << 5) //初始化并排LED被按位或的参数 #define BSP_LED_1_ON (1 << 6) #define BSP_LED_2_ON (1 << 7) #define BSP_LED_3_ON (1 << 8) #define BSP_LED_4_ON (1 << 9) #define BSP_LED_5_ON (1 << 10) #define BSP_LED_6_ON (1 << 11) #define BSP_LED_7_ON (1 << 12) #define BSP_LED_8_ON (1 << 13) /* Exported types ------------------------------------------------------------*/ /** * @brief 板上DC24工作状态 * */ enum Enum_BSP_DC24_Status { BSP_DC24_Status_DISABLED = 0, BSP_DC24_Status_ENABLED, }; /** * @brief 板上LED工作状态 * */ enum Enum_BSP_LED_Status { BSP_LED_Status_ENABLED = 0, BSP_LED_Status_DISABLED, }; /* Exported variables --------------------------------------------------------*/ /* Exported function declarations --------------------------------------------*/ void BSP_Init(uint32_t Status, float IMU_Heater_Rate = 0, float Buzzer_Rate = 0); void BSP_DC24_LU(Enum_BSP_DC24_Status Status); void BSP_DC24_LD(Enum_BSP_DC24_Status Status); void BSP_DC24_RU(Enum_BSP_DC24_Status Status); void BSP_DC24_RD(Enum_BSP_DC24_Status Status); void BSP_LED_R(Enum_BSP_LED_Status Status); void BSP_LED_G(Enum_BSP_LED_Status Status); void BSP_LED_1(Enum_BSP_LED_Status Status); void BSP_LED_2(Enum_BSP_LED_Status Status); void BSP_LED_3(Enum_BSP_LED_Status Status); void BSP_LED_4(Enum_BSP_LED_Status Status); void BSP_LED_5(Enum_BSP_LED_Status Status); void BSP_LED_6(Enum_BSP_LED_Status St
最新发布
03-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值