Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
/************************************* SEGMENT***********************************/
#define pin_a RB6_bit
#define pin_b RB7_bit
#define pin_c RB1_bit
#define pin_d RB2_bit
#define pin_e RB3_bit
#define pin_f RB5_bit
#define pin_g RB4_bit
#define pin_dp RB0_bit
/*********************** LED**********************/
#define led_1 RB4_bit
#define led_2 RB0_bit
#define led_3 RB1_bit
#define led_4 RB2_bit
#define led_5 RB3_bit
/******************** CATHOD *****************/
#define cc_1 RC6_bit
#define cc_2 RC7_bit
#define cc_3 RC3_bit
#define cc_4 RC4_bit
#define led_gnd RC5_bit
/******************** KEY**************************/
#define sw_up RA4_bit
#define sw_dwn RA2_bit
#define sw_strt RA5_bit
#define buzz RC2_bit
#define relay RA1_bit
unsigned char disp_1[10] = {0xef,0x83,0xdd,0xd7,0xb3,0x77,0x7f,0xc3,0xff,0xf7};
unsigned char disp_2[10] = {0x7f,0x1c,0xbb,0xbe,0xdc,0xee,0xef,0x3c,0xff,0xfe};
unsigned int ins_unit,ins_dec,dec;
int unit;
void keypad()
{
if(sw_up == 0)
{
if(dec==9 && unit==9);
else
{
unit=unit+1;
if(unit>9)
{unit=0;dec=dec+1;}delay_ms(50);
}
}
if(sw_dwn == 0)
{
if(dec==0 && unit==0);
else
{
unit=unit-1;
if(unit<0)
{unit=9;dec=dec-1;}delay_ms(50);
}
}
}
void main()
{
int x;
TRISA = 0b00110101;
//TRISA = 0xff;
//TRISA=0b00000000;
TRISB = 0X00;
TRISC = 0x00;
relay=0;// relay 0 to onn and 1 to off
delay_ms(500) ;
led_gnd=cc_1=cc_2=cc_3=cc_4=1;
unit=0,dec=0;ins_unit=0,ins_dec=0;;
while(1)
{
for(x=0;x<50;x++)
{
cc_3=1;cc_2=0;
PORTB=disp_2[unit];
keypad();delay_ms(5);
cc_2=1;cc_1=0;
PORTB=disp_1[dec];
keypad();delay_ms(5);
cc_1=1;cc_4=0;
PORTB=disp_2[ins_unit];
keypad();delay_ms(5);
cc_4=1;cc_3=0;
PORTB=disp_1[ins_dec];
keypad();delay_ms(5);
}
}
}
Means what?But it is not working properly.
One thing,when i choose PIC16f722 in place of PIC16f72 i get same config word 0x3fb2 and get some output using pic16f72 controller.
Iam able to display value(00-99) in timer sec and now trying to increse and decrese it with switch.
; CONFIG1
; __config 0x20F1
__CONFIG _CONFIG1, _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _IESO_OFF & _FCMEN_OFF & _LVP_OFF
; CONFIG2
; __config 0xFFFF
__CONFIG _CONFIG2, _BOR4V_BOR40V & _WRT_OFF
Have you tried with another pic16f72 microcontroller? just in case if the MCU is damaged.
I am sharing the below configuration settings for PIC16F886 MCU, which you can refer as an example,
Code:; CONFIG1 ; __config 0x20F1 __CONFIG _CONFIG1, _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _IESO_OFF & _FCMEN_OFF & _LVP_OFF ; CONFIG2 ; __config 0xFFFF __CONFIG _CONFIG2, _BOR4V_BOR40V & _WRT_OFF
Ref: **broken link removed**
the example which they have given in the above website, i have tried and it was working.
void main()
{
int x;
// TRISA = 0b00110101;
TRISA = 0xff;
//TRISA=0b00000000;
TRISB = 0X00;
TRISC = 0x00;
relay=0;// relay 0 to onn and 1 to off
delay_ms(500) ;
led_gnd=cc_1=cc_2=cc_3=cc_4=1;
unit=0,dec=0;ins_unit=0,ins_dec=0;;
while(1)
{
for(x=0;x<50;x++)
{
cc_3=1;cc_2=0;
PORTB=disp_2[unit];
delay_ms(50);
cc_2=1;cc_1=0;
PORTB=disp_1[dec];
delay_ms(50);
cc_1=1;cc_4=0;
PORTB=disp_2[ins_unit];
delay_ms(50);
cc_4=1;cc_3=0;
PORTB=disp_1[ins_dec];
delay_ms(50);
}
if(unit==9 && dec == 9)
;
else
{
unit=unit++;
if(unit>9)
{unit=0;dec=dec+1;}
}
}
}
unit=unit++;
Code Basic4GL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 'Proton Basic Code '**************************************************************** Device = 16F72 ;------------------------------------------------------------------------------- ;**** Added by Fuse Configurator **** ; Use the Fuse Configurator plug-in to change these settings Config FOSC_XT, WDTE_OFF, PWRTE_ON, CP_OFF, BOREN_OFF ;**** End of Fuse Configurator Settings **** ;------------------------------------------------------------------------------- Declare Xtal 4 TRISB=%00000000; PORTB=%00000000; Main: PORTB=%10101010 DelayMS 500 PORTB=0 DelayMS 100 GoTo Main End