LEDバーアレイ
output_low(PIN_B5); output_high(PIN_B5);次に、B4 にht個のパルスを送ります。
for(i=0;i<ht;i++){ output_high(PIN_B4); output_low(PIN_B4); }これで、QAから順に ht 個の出力を1に設定できます。たとえば、htを3にすると、QA,QB,QC が1になります。
#include <16F873A.h> //LED Bar //B5:CLR //B4:CLK #fuses HS,NOWDT,NOLVP #use delay(clock = 20000000) int ht,i; void main(){ output_high(PIN_B5); output_low(PIN_B4) ; while(1){ for(ht=0;ht<9;ht++){ //clear all output_low(PIN_B5); output_high(PIN_B5); output_low(PIN_B4); //set ht bits for(i=0;i<ht;i++){ output_high(PIN_B4); output_low(PIN_B4); } delay_ms(200); } }//while }