Cannot pass pass variable to 'Toggle' function.

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Francesco.C
Posts: 41
Joined: Thu Feb 26, 2009 6:54 pm
Location: UK

Cannot pass pass variable to 'Toggle' function.

Post by Francesco.C » Sun Jul 26, 2009 6:25 pm

Hi there,

I have a bank of LEDs connected on PORTB that I want to toggle at random
by passing a variable to the 'Toggle' function.

For example
...................................
Sub Light(x as bit )
toggle(x)
End sub

Light(portb.2)

Light(portb.5)
............................

The code above gives this error: "Parameter must be a single port pin".

I cannot see what is wrong with it!
But because I am new to this, probably there is something that must be very obvious to you guys.


Any help is welcome.

Regards

Francesco C.

Morris
Registered User
Registered User
Posts: 15
Joined: Mon Feb 09, 2009 8:13 pm
Location: Mexico
Contact:

Post by Morris » Sun Jul 26, 2009 7:36 pm

Try

sub Light(Byref Pin as bit)
toggle(Pin)
end sub

...............

Light(portb.1)

this works

Francesco.C
Posts: 41
Joined: Thu Feb 26, 2009 6:54 pm
Location: UK

Post by Francesco.C » Sun Jul 26, 2009 7:50 pm

Thank you Morris,

It works fine.

I did think was something like that.
I have used SW on and off since February and I have relied on you guys
to help me when I am stuck.

Thank.

Francesco C.

Post Reply