AND logic in PBASIC?
meredth78
Posts: 18
hi guys,
i need to write a conditional AND logic statement.· i am trying to control a series of leds depending on the postion of spdt on1-off-on2 switch and a seperate·input signal. something like...
switch position on1· =>· if pin1 and pin3·= high, then·pin 4 = high
switch position on2· =>· if pin2 and pin3·= high, then pin 4 = high
switch position·off · =>· if·pin3·= high, and pin1 = low,·and pin2 = low, then pin 4 = high
i'm sure there are a multitude of better ways to do this and i am open to any and all possibilities. i haven't·been programming long enough·to know what will and won't work, yet. what i am trying to do is change the flash rate of an led to one of three options using the same triggering input but changing the switch position.
thanks fellas
i need to write a conditional AND logic statement.· i am trying to control a series of leds depending on the postion of spdt on1-off-on2 switch and a seperate·input signal. something like...
switch position on1· =>· if pin1 and pin3·= high, then·pin 4 = high
switch position on2· =>· if pin2 and pin3·= high, then pin 4 = high
switch position·off · =>· if·pin3·= high, and pin1 = low,·and pin2 = low, then pin 4 = high
i'm sure there are a multitude of better ways to do this and i am open to any and all possibilities. i haven't·been programming long enough·to know what will and won't work, yet. what i am trying to do is change the flash rate of an led to one of three options using the same triggering input but changing the switch position.
thanks fellas
Comments
If that's correct, then all you need for your statement is "out4 = in3". Somehow that doesn't seem like what you really want.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
0······0·······1········1······················· Rate A
0······1·······1········1······················· Rate B
1······0·······1········1······················· Rate C·············
1······1·······1········not·possible
X······X·······0········0······················· Behavior not specified by meredth78 (e.g.,
······························································· LED off?; on at previous rate?, ...?)
So, depending on how the program is structured to produce the several flash rates,·would suggest how·you'd have to factor in the actual value of in1 and/or in2.
Only if Rate A = Rate B = Rate C would it be sufficient to know just in3 (ignoring the undefined ·case of what to do when in3 is 0).
PAR