Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC, Basic language question

Status
Not open for further replies.

rezaf

Advanced Member level 4
Joined
Apr 11, 2009
Messages
106
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
Montagram
Activity points
2,147
Hello
I work on a project similar to calculator but have a problem and be happy if someone help me. in this project there are PIC16F887, keypad and GLCD that user must enter numbers. I want similar to calculator the user able to enter numbers and see on GLCD and then the numbers save in a variable but I can't save all numbers that enter in a one variable and always the latest number save in variable please help me to resolve this problem. I write my code in basic language. the number is 3 digit and have decimal (for example 2/5 or 2.5)
I can't show decimal point on GLCD and save to variable too.
thanks for your helps.


wl:
T6963C_GrFill(0)
T6963C_TxtFill(0)
T6963C_write_text("Please Enter number !", 2, 4, T6963C_ROM_MODE_XOR)
T6963C_write_text("the Number : ", 2, 8, T6963C_ROM_MODE_XOR)
T6963C_write_text("9.Return to Home", 14, 15, T6963C_ROM_MODE_XOR)
cnt = 0
wlset:
do
kp = 0 ' Reset key code variable

' Wait for key to be pressed and released
while (kp = 0)
kp = Keypad_Key_Click() ' Store key code in kp variable
wend

select case kp
case 1
kp = 1 ' 1
case 2
kp = 2 ' 2
case 3
kp = 3 ' 3
case 4
kp = 4 ' 4
case 5
kp = 5 ' 5
case 6
kp = 6 ' 6
case 7
kp = 7 ' 7
case 8
kp = 8 ' 8
case 9
kp = 9 ' 9
case 10
kp = 46 ' * ,decimal point's Ascii code
case 11
kp = 0 ' 0
case 16
kp = 68 ' D
end select
loop until kp>0

if (kp = 9) then
goto home
end if

do
inc(cnt)
if (cnt = 1) then ' I try to resolve my problem by this codes but can't.
wl1 = kp
goto wlset
end if
if (cnt = 2) then
wl2 = kp
goto wlset
end if
if (cnt = 3) then
wl3 = kp
goto wlset
end if
loop until cnt>4

wl = wl1&wl2&wl3 'wl is the variable for 3 digit number
ByteToStr(wl, txt1)
T6963C_write_text(txt1, 15, 8, T6963C_ROM_MODE_XOR)
T6963C_write_text("unit", 22, 8, T6963C_ROM_MODE_XOR)
T6963C_Cursor(0)
delay_ms (3000)
 

One way is to save all the numbers to an array and then make the conversion to a single number.
 

the compiler can't convert array to integer or word and when I want to convert to string to display on GLCD give error too .how to convert array to one integer?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top