PDA

View Full Version : Problems with variable - Advise welcome



tracking
- 9th June 2005, 16:17
Hi
Use PicBasic Pro

Anybody give some advise as to setting a variable for example

a var BYTE
b ......

a=0
b=0
c=0

if a=1 then ...

if b=1 then

if c=1 then

All this is ignored and the 'if' statements are performed even though all the variables are set to '0'. Is there something special you have to do.

Thanks

tracker

leonel
- 13th June 2005, 18:26
There´s no apparent reason to doesn´t work!

Bruce
- 13th June 2005, 18:40
Post the code you're having problems with. That makes it a lot easier
for folks to help.

Here's a simple test with 3 LED's connected to PortB pins 0-2 to see how
it's working.

Portb.0 -------|>|---/\/\/\--- gnd
Portb.1 -------|>|---/\/\/\--- gnd
Portb.2 -------|>|---/\/\/\--- gnd


A VAR BYTE
B VAR BYTE
C VAR BYTE

A = 1
B = 0
C = 1

Main:
IF A = 1 then HIGH 0 ' PortB.0 LED on
IF B = 1 then HIGH 1 ' PortB.1 LED on
IF C = 1 Then High 2 ' PortB.2 LED on
Goto Main


LED's on RB.0 & RB.2 turn on while the one on RB.1 stays off.