Matrix scankey 3×4 for Lcd 2 line For CSS Compiler




 
#include <16F877.h>
#device adc=8
#FUSES NOWDT ,XT                                        
#use delay(clock=4000000)
char const s[10]={'0','1','2','3','4','5','6','7','8','9'}; 
void init_mcu  (void); 
void display (void);
void display1 (void);
void calculate (void);
void hex_bcd2(int8 k);
/*-------define keypad------------*/
#define row0  pin_b0 // input
#define row1  pin_b1 // input
#define row2  pin_b2 // input
#define row3  pin_b3 // input
#define col0  pin_b4 // output
#define col1  pin_b5 // output
#define col2  pin_b6 // output
/*------set variable -----------*/
int8 digit=0;
int16 value1,value2;
int8 set[34];
int8 i=0,k=0;
#include "lcd_4bit.c"
#include "get_key3x4.c"
void main(void){
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
set_tris_B(0x0f);
set_tris_D(0x00);
output_high(col0);
output_high(col1);
output_high(col2);
output_high(row0);
output_high(row1);
output_high(row2); 
output_high(row3); 
value1 = 0;
value2 = 0;
i = 0;
set[0]=0;
lcd_init();
init_mcu();
delay_ms(2000); 
lcd_clear();
while(true){    
scan_key();
display();  
}
}
void init_mcu (void){
lcd_row_col(1,0);
lcd_putc("Electric Power   ");
lcd_row_col(2,0);
lcd_putc("Kchimicro.PIC    ");  
}
void hex_bcd2(int8 k){
k%=10;
a=0;b=0; 
b=k%10;
b=k;
}
void hex_bcd1(int16 k){
a=0; b=0;c=0;d=0;e=0;
while(k>=10000){
a++;
k -= 10000;} 
while(k>=1000){
b++;
k -= 1000;}    
while(k>=100){
c++;
k -= 100;}
while(k>=10){
d++;
k-=10;}
e=k;
}
void display (void){
lcd_row_col(1,0);
hex_bcd2(set[i]);
lcd_row_col(1,i-1);
lcd_putc(s[b]); 
delay_ms(10);
/*--------------------------------*/   
if (i > 16){  
hex_bcd2(set[i]);
lcd_row_col(2,i-17);
lcd_putc(s[b]);} 
delay_ms(10);
}
void calculate (void){
if (k<10){ 
if (digit++>31){digit=0;i = 0;}
else {i++;set[i] = k;}}               
if(k== 11){
do{
value1--;
display();
delay_ms(500);
}while(value1>0);
digit=0;value1 = 0; i=0;
}     
}




Current Project / Post can also be found using:

  • ccs 3×4 matrix
READ  Wye-delta Motor Controll For CSS Compiler

Leave a Comment

*
= 3 + 7

Read previous post:
A Beginner’s data logger project using PIC12F683 microcontroller Schematic
A Beginner’s data logger project using PIC12F683 microcontroller

It is a very simple data logger project based on PIC12F683 microcontroller. The microcontroller reads temperature values from a temperature...

Close
Scroll to top