Rohith_elec
Full Member level 4
How can we define a value to a pushbutton ?
i made a code in mikroC, but some problems in int to ptr
i made a code in mikroC, but some problems in int to ptr
Code:
// LCD module connections
sbit LCD_RS at RD2_bit; // for writing to output pin always use latch (PIC18 family)
sbit LCD_EN at RD3_bit; // for writing to output pin always use latch (PIC18 family)
sbit LCD_D4 at RD4_bit; // for writing to output pin always use latch (PIC18 family)
sbit LCD_D5 at RD5_bit; // for writing to output pin always use latch (PIC18 family)
sbit LCD_D6 at RD6_bit; // for writing to output pin always use latch (PIC18 family)
sbit LCD_D7 at RD7_bit; // for writing to output pin always use latch (PIC18 family)
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
#define A Button(&PORTB, 0, 1, 1)
#define B Button(&PORTB, 1, 1, 1)
#define C Button(&PORTB, 2, 1, 1)
#define D Button(&PORTB, 3, 1, 1)
void main() {
char A1,B1,C1,D1;
ADCON1 |= 0x0F; // Configure AN pins as digital
CMCON |= 7; // Disable comparators
IntToStr(A, A1);
IntToStr(B, B1);
IntToStr(C, C1);
IntToStr(D, D1);
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,6,A1); // Write text in first row
Lcd_Out(2,6,B1); // Write text in second row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,1,C1); // Write text in first row
Lcd_Out(2,5,D1); // Write text in second row
Delay_ms(2000);
}