PDA

View Full Version : input command (newbie question)



kctan
- 23rd November 2005, 15:39
i am new and i write the input code in microcode studio plus like this
i using PIC16F877A

define osc 20
trisa = %111111
trisb = %00000000
x var byte
start:
if porta.0 = 1 then
portb.0 = 1
else
portb = %00000000
endif
when i simulate in proteus 6, i got nothing at output LED
when i was pressed a switch in proteus, it got signal go in and the voltage is 5.33 after when at open switch i find that porta.0 pin still got voltage that is 3.44 wat is the problem
wat's wrong with my coding?

define osc 20
trisa = %111111
trisb = %00000000
x var byte
start:
x=0
while porta.0 =1 and x = 10
portb.0 = 1
x=x+1
wend
with this code i'am also cannot work so wat is my problem in input?
does my program write wrong?

Darrel Taylor
- 23rd November 2005, 22:55
Hi kctan,

Nothing wrong with the first example. Except there's no GOTO at the end to form a loop. (but you probably just missed it with the cut&paste) You might want to try it on a real chip, instead of a simulator.

However, in the second example.
x=0
while porta.0 =1 and x = 10
portb.0 = 1
x=x+1
wend
The "while" will never execute, because x = 10 will never be True.

Also, the code shown would be for PicBasic Pro, Plain PicBasic doesn't have a "while" command.

kctan
- 24th November 2005, 07:20
thanks you