PIC Basic Plus and RS232 problem again. Help!!!

Status
Not open for further replies.

Beefer3

New Member
Hey everyone
Can someone help out on the following code?

The first two IF THEN statements work but, the switch IF THEN statement does not.

When I run the code with the first two IF THEN statements commented out, the switch IF THEN statement is recognized.

Also, if I hold down the switch and press A or B on my terminal program, the switch IF THEN statement is recognized.

I am completely confused as to why it does not work.

Any help is greatly appreciated.


Here is the code:

DEVICE 16F84A
INCLUDE "MODEDEFS.BAS"
PORTA = %10111
PORTB = %00000000


Cls
Print AT 1, 1, " WELCOME"

Dim SERDATA As Byte

SINPUT:
SERIN PORTA.4, 396, [SERDATA]

If SERDATA = "A" Then
SEROUT PORTA.3,396, ["SENDING THE LETTER A"]
Cls
Print AT 1, 1, "SENDING THE"
Print AT 2, 1, "LETTER A"
Else
End If


If SERDATA = "B" Then
SEROUT PORTA.3,396, ["SENDING THE LETTER B"]
Cls
Print AT 1, 1, "SENDING THE"
Print AT 2, 1, "LETTER B"
Else
End If


IF PORTA.2 = 1 THEN
Cls
Print AT 1, 1, "SWITCH PUSHED"
SEROUT PORTA.3,396,[ "SWITCH PUSHED"]
Else
End If

GOTO SINPUT

End
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…