passing pin as arg to subroutine?
Ben Kirkpatrick
Posts: 7
·· I'm kinda new to SX/B and was hoping there's a way to pass pins to a subroutine.· I've tried it a couple different ways, but run into compiler errors.· I tried both acting on __PARAM1 directly and passing to a temp VAR, but it doesn't seem to fit into Bit or Byte.· What is the internal shape of a pin definition?
For example there are four LEDs:
blue VAR RB.4
red VAR RB.3
green VAR RB.2
white VAR RB.1
FADEIN SUB 2 ' pin name and speed
FADEOUT SUB 2 ' pin name and speed
FLICKER SUB 2 ' pin name and duration
start_point:
FADEIN blue,50
FADEOUT white,10
FADEIN green, 100
' the end
FADEIN:
· for COUNT = 0 to 250
··· pwm __PARAM1, COUNT, __PARAM2
· next
· __PARAM1 = 1 ' leave it on
RETURN
' Or perhaps?
FADEIN:
· TEMPPIN = __PARAM1 ' what kind of data am I ?
· for COUNT = 0 to 250
··· pwm TEMPPIN, COUNT, __PARAM2
· next
· __PARAM1 = 1 ' leave it on
RETURN
PS: As a side note... anyone used SOUND to simulate a heartbeat?
Thanks.
--Ben
For example there are four LEDs:
blue VAR RB.4
red VAR RB.3
green VAR RB.2
white VAR RB.1
FADEIN SUB 2 ' pin name and speed
FADEOUT SUB 2 ' pin name and speed
FLICKER SUB 2 ' pin name and duration
start_point:
FADEIN blue,50
FADEOUT white,10
FADEIN green, 100
' the end
FADEIN:
· for COUNT = 0 to 250
··· pwm __PARAM1, COUNT, __PARAM2
· next
· __PARAM1 = 1 ' leave it on
RETURN
' Or perhaps?
FADEIN:
· TEMPPIN = __PARAM1 ' what kind of data am I ?
· for COUNT = 0 to 250
··· pwm TEMPPIN, COUNT, __PARAM2
· next
· __PARAM1 = 1 ' leave it on
RETURN
PS: As a side note... anyone used SOUND to simulate a heartbeat?
Thanks.
--Ben
Comments
In SX/B pins are NOT numbered like they are on the stamps.
When the PWM command is converted to assembly code the pin must be a constant.
You'll need to use a different PWM command for each pin.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"I reject your reality, and substitute my own." Mythbusters
·