[mw_shl_code=c,true]我希望能同时点亮它们,求代码[/mw_shl_code]
[mw_shl_code=c,true]
[/mw_shl_code]
[mw_shl_code=c,true]
[/mw_shl_code]
[mw_shl_code=c,true]
[/mw_shl_code]
[mw_shl_code=c,true]#include "stm32f10x.h"
#include "SysTick.h"
#include "led.h"
#include "KEY.h"
#include "LED.h"
#include "TIMER.h"
/*
* 函数名:main
* 描述 :主函数
* 输入 :无
* 输出 :无
*/
int main(void)
{
int count=0;
int count1=0;
SysTick_Init();
Timerx_Init(1,720);
SEGTABLE_INIT();
LED_GPIO_Config();
LED_SEL(1);
Key_Config_Operation(1,1,1);
while(1)
{
if(flag_100us==1)
{
KEY_CHECK(1,1,1);
if(key1_flag) //key1按下去采取的动作
{
key1_flag=0;
if(count1%2==0)
{
if(count>=0&&count<8)
{
count++;
}
else
count==8;
switch(count)
{
// LED0 = light&0x01
// LED1 = light&0x02
// LED2 = light&0x04
// LED3 = light&0x08
// LED4 = light&0x10
// LED5 = light&0x20
// LED6 = light&0x40
// LED7 = light&0x80
case 0: LedValue(0x00); break;
case 1: LedValue(0x01); break;
case 2: LedValue(0x03); break;
case 3: LedValue(0x07); break;
case 4: LedValue(0x0f); break;
case 5: LedValue(0x1f); break;
case 6: LedValue(0x3f); break;
case 7: LedValue(0x7f); break;
case 8: LedValue(0xff); break;
}
}
else
LedValue(0xff); //当LED灯全亮时,K1,K2键锁死
}
if(key2_flag) //key2按下去采取的动作
{
key2_flag=0;
if(count1%2==0)
{
if(count>0&&count<=8)
{
count--;
}
else
count==0;
switch(count)
{
case 0: LedValue(0x00); break;
case 1: LedValue(0x01); break;
case 2: LedValue(0x03); break;
case 3: LedValue(0x07); break;
case 4: LedValue(0x0f); break;
case 5: LedValue(0x1f); break;
case 6: LedValue(0x3f); break;
case 7: LedValue(0x7f); break;
case 8: LedValue(0xff); break;
}
}
else
LedValue(0xff);
}
if(key3_flag) //key3按下去采取的动作
{
key3_flag=0;
count1++;
switch(count1%2)
{
case 0: switch(count)
{
case 0: LedValue(0x00); break;
case 1: LedValue(0x01); break;
case 2: LedValue(0x03); break;
case 3: LedValue(0x07); break;
case 4: LedValue(0x0f); break;
case 5: LedValue(0x1f); break;
case 6: LedValue(0x3f); break;
case 7: LedValue(0x7f); break;
case 8: LedValue(0xff); break;
} break;
case 1: LedValue(0xff); break;
}
}
}
}
}
[/mw_shl_code]
[mw_shl_code=c,true][/mw_shl_code]
|