📄 7seg_dec_sw.c.c
字号:
// 7SEG_dec_sw.C
//Example to drive one 7-Segment LED with decriment by one when press switch
/****************************************
*
* COPYRIGHT (c) Blitzlogic Sdn. Bhd.
* Author : Abraham Wong 21/1/2000
*
* example of using FOR loop to drive
* two 7-Segment LEDs
****************************************/
#include <16F877.h>
#USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */
#FUSES XT,NOWDT,NOPROTECT,NOPUT,NOLVP
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
/* Use XT mode, No Watch Dog, No Code Protect, No Power-up Timer */
#byte port_d=8 /* define the location of register port_b */
#byte port_a=5 /* define the location of register port_b */
byte CONST LED_MAP[10] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0X80,0x90};
main(){
byte cnt, right,num ;
port_b_pullups(true);
set_tris_d(0); /* set port_b as outputs */
set_tris_a(0); /* set port_a as output */
port_d = 0xFF; /* ZERO port_a & port_b */
port_a = 0xFF;
while(1){
//for( ;; ){
// for (right=1;right<3;right++){
// port_a = ~right;
for (cnt=9;cnt<10;cnt--){
port_d = LED_MAP[cnt];
output_low(PIN_A0);
DELAY_MS(500); /* half second delay */
// output_high(PIN_A0);
while(!input(PIN_B1)==0){
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -