heina
Junior Member level 3
- Joined
- Dec 21, 2009
- Messages
- 25
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Philippines
- Activity points
- 1,471
program calculator
dim LCD_RS as sbit at RB4_bit
LCD_EN as sbit at RB5_bit
LCD_D4 as sbit at RB0_bit
LCD_D5 as sbit at RB1_bit
LCD_D6 as sbit at RB2_bit
LCD_D7 as sbit at RB3_bit
LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
dim keypadPort as byte at PORTD
dim kp as byte
dim ky as byte
dim key as byte[20]
dim ks as string[20]
dim temp as word
sub procedure GlobInit
TRISA = 0
TRISB = 0
LCD_Init
LCD_Cmd(_LCD_CLEAR)
LCD_Cmd(_LCD_CURSOR_OFF)
Keypad_Init
ADCON1 = 7
end sub
main:
GlobInit
while true
for temp = 0 to 3
kp = 0
while (kp = 0)
kp = Keypad_Key_Click
wend
select case kp
case 1 ky = 7
case 2 ky = 4
case 3 ky = 1
case 4 ky = 10
case 5 ky = 8
case 6 ky = 5
case 7 ky = 2
case 8 ky = 0
case 9 ky = 9
case 10 ky = 6
case 11 ky = 3
case 12 ky = 11
case 13 ky = 12
case 14 ky = 13
case 15 ky = 14
case 16 ky = 15
end select
if (ky < 11) then
key[temp] = ky
ks[temp] = ky + 48
end if
if (ky > 10) then
break
end if
LCD_Out(1,1,ks)
next temp
kp = 0
while (kp = 0)
kp = Keypad_Key_Click
wend
wend
end.
select case kp
case 1 ky = 1
case 2 ky = 4
case 3 ky = 7
case 4 ky = -6
case 5 ky = 2
case 6 ky = 5
case 7 ky = 8
case 8 ky = 0
case 9 ky = 3
case 10 ky =6
case 11 ky =9
case 12 ky = -13
case 13 ky = 17 'A
case 14 ky = 18 'B
case 15 ky = 19 'C
case 16 ky = 20 'D
end select
if (ky < 11) then
key[temp] = ky
ks[temp] = ky + 48
end if
program calculator
dim LCD_RS as sbit at RB4_bit
LCD_EN as sbit at RB5_bit
LCD_D4 as sbit at RB0_bit
LCD_D5 as sbit at RB1_bit
LCD_D6 as sbit at RB2_bit
LCD_D7 as sbit at RB3_bit
LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
dim keypadPort as byte at PORTD
dim kp as byte
dim ky as char
dim key as byte[20]
dim ks as string[20]
dim temp as word
sub procedure GlobInit
TRISA = 0
TRISB = 0
LCD_Init
LCD_Cmd(_LCD_CLEAR)
LCD_Cmd(_LCD_CURSOR_OFF)
Keypad_Init
ADCON1 = 7
end sub
main:
GlobInit
for temp = 0 to 3
kp = 0
while (kp = 0)
kp = Keypad_Key_Click
wend
select case kp
case 1 ky = "1"
case 2 ky = "4"
case 3 ky = "7"
case 4 ky = "*"
case 5 ky = "2"
case 6 ky = "5"
case 7 ky = "8"
case 8 ky = "0"
case 9 ky = "3"
case 10 ky = "6"
case 11 ky = "9"
case 12 ky = "#"
case 13 ky = "A"
case 14 ky = "B"
case 15 ky = "C"
case 16 ky = "D"
end select
ks[temp] = ky
LCD_Out(1,1,ks)
next temp
while true
wend
end.
for temp = 0 to 3
can u share it project with us........heina said:Hi Tahmid!!
great news.. After a lot of experimentation, it worked on pic simulator ide, the one that I just started using. I just had to configure it right and observe for a few moments. We'll be making the hardware soon. Thank you so much for all the help. I hope you will never get tired in helping people like me.
Until next time.
Sincerely,
Heina
heina said:Hi guys. I've been looking for an example written in Mikrobasic using a keypad which will accept 4 numbers then display a message in LCD. But, so far I can't find one. I found some written in C but I'm not really familiar with that and I'm just starting out in Mikrobasic...So, I've been trying to find one which I can use.
Any help would be very much appreciated.
Thank you and --- Bless.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?