六行三列LED灯,通过三极管接到9个IO口上,静态的时候亮度很足,。现在要让LED灯闪动,把闪动的函数放在中断里,亮度就很低。。
R代表行,L代表列,ON点亮,OFF灭
void fun1(void)
{
R1_ON;
L1_ON;L1_OFF;
L2_ON;L2_OFF;
L3_ON;L3_OFF;
R1_OFF;
switch(sta)
{
case 1:
//ROW2
R2_ON;
L1_ON;
L1_OFF;
R2_OFF;
break;
case 2:
//ROW2
R2_ON;
L1_ON;
L1_OFF;
R2_OFF;
//ROW3
R3_ON;
L1_ON;
L1_OFF;
R3_OFF;
break;
case 3:
//ROW2
R2_ON;
L1_ON;
L1_OFF;
R2_OFF;
//ROW3
R3_ON;
L1_ON;
L1_OFF;
R3_OFF;
//ROW4
R4_ON;
L1_ON;
L1_OFF;
R4_OFF;
break;
case 4:
//ROW2
R2_ON;
L1_ON;
L1_OFF;
R2_OFF;
//ROW3
R3_ON;
L1_ON;
L1_OFF;
R3_OFF;
//ROW4
R4_ON;
L1_ON;
L1_OFF;
R4_OFF;
//ROW5
R5_ON;
L1_ON;
L1_OFF;
R5_OFF;
break;
case 5:
//ROW1
R1_ON;
L1_ON;
L1_OFF;
R1_OFF;
//ROW3
R3_ON;
L1_ON;
L1_OFF;
R3_OFF;
//ROW4
R4_ON;
L1_ON;
L1_OFF;
R4_OFF;
//ROW5
R5_ON;
L1_ON;
L1_OFF;
R5_OFF;
break;
case 6:
//ROW1
R1_ON;
L1_ON;
L1_OFF;
R1_OFF;
//ROW5
R5_ON;
L1_ON;
L1_OFF;
R5_OFF;
break;
case 7:
//ROW2
R2_ON;
L2_ON;L3_ON;
L2_OFF;L3_OFF;
R2_OFF;
break;
case 8:
//ROW2
R2_ON;
L3_ON;
L3_OFF;
R2_OFF;
//ROW3
R3_ON;
L3_ON;
L3_OFF;
R3_OFF;
break;
case 9:
//ROW2
R2_ON;
L3_ON;
L3_OFF;
R2_OFF;
//ROW3
R3_ON;
L3_ON;
L3_OFF;
R3_OFF;
//ROW4
R4_ON;
L3_ON;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_OFF;
break;
case 18:
//ROW1
R1_ON;
L2_ON;
L2_OFF;
R1_OFF;
//ROW3
R3_ON;
L2_ON;
L2_OFF;
R3_OFF;
//ROW4
R4_ON;
L2_ON;
L2_OFF;
R4_OFF;
//ROW5
R5_ON;
L3_ON;
L3_OFF;
R5_OFF;
//ROW6
R6_ON;
L2_ON;
L2_OFF;
R6_OFF;
break;
case 19:
//ROW4
R4_ON;
L2_ON;
L2_OFF;
R4_OFF;
//ROW5
R5_ON;
L3_ON;
L3_OFF;
R5_OFF;
//ROW6
R6_ON;
L2_ON;
L2_OFF;
R6_OFF;
break;
case 20:
//ROW5
R5_ON;
L3_ON;
L3_OFF;
R5_OFF;
//ROW6
R6_ON;
L2_ON;
L2_OFF;
R6_OFF;
break;
case 21:
//ROW6
R6_ON;
L2_ON;
L2_OFF;
R6_OFF;
break;
case 22:
//ROW2
R2_ON;
L1_ON;
L1_OFF;
R2_OFF;
break;
case 23:
//ROW2
R2_ON;
L1_ON;
L1_OFF;
R2_OFF;
//ROW3
R3_ON;
L1_ON;
L1_OFF;
R3_OFF;
break;
case 24:
//ROW2
R2_ON;
L3_ON;
L3_OFF;
R2_OFF;
break;
case 25:
//ROW2
R2_ON;
L3_ON;
L3_OFF;
R2_OFF;
//ROW3
R3_ON;
L3_ON;
L3_OFF;
R3_OFF;
break;
case 26:
//ROW2
R2_ON;
L2_ON;
L2_OFF;
R2_OFF;
break;
case 27:
//ROW2
R2_ON;
L2_ON;
L2_OFF;
R2_OFF;
//ROW3
R3_ON;
L2_ON;
L2_OFF;
R3_OFF;
break;
case 28:
sta=1;
break;
default:
sta=1;
break;
}
} |