Hello All,
Possibly someone can help me rid my program of zillions of "If Then" statements.
I have 8) 5 volt relays (via 2N7000's) connected to output pins B.0 - B.7 on my PICAXE 18M2 chip. I capture DTMF tones (from a key pad ) in byte b0. This is a number between 1 and 8, to determine which of the 8 relays to turn on or off. (only one relay on or off at a time!) In byte b1 is (a key press) either the number 0 or 1. You guessed it, 0 = off, 1 = on.
I currently have it pretty much working but I have 8 IF THEN's to determine which relay to turn on and 8 IF THEN's to determine which relay to turn off.
Example:
If b0 = 4 And b1 = 1 Then High b.3 (turns relay #4 on)
If b0 = 7 And b1 = 0 Then Low b.6 (turns relay #7 off)
Couldn't the 8 IF/THEN statements to turn on relays be reduced to something like HIGH B.b0 or HIGH B.#b0 ??? Wishful thinking Obviously these produce syntax errors. But certainly there is a better way then a zillion IF/THEN's .
And again the same for 8 IF/THEN statements to turn off relays, LOW B.b0 or LOW b.#b0
Famous quote (from me) "I bet it's simple, but sometimes simple is too hard for me".
Thanks in advance.
"Ham Radio Addict"
Possibly someone can help me rid my program of zillions of "If Then" statements.
I have 8) 5 volt relays (via 2N7000's) connected to output pins B.0 - B.7 on my PICAXE 18M2 chip. I capture DTMF tones (from a key pad ) in byte b0. This is a number between 1 and 8, to determine which of the 8 relays to turn on or off. (only one relay on or off at a time!) In byte b1 is (a key press) either the number 0 or 1. You guessed it, 0 = off, 1 = on.
I currently have it pretty much working but I have 8 IF THEN's to determine which relay to turn on and 8 IF THEN's to determine which relay to turn off.
Example:
If b0 = 4 And b1 = 1 Then High b.3 (turns relay #4 on)
If b0 = 7 And b1 = 0 Then Low b.6 (turns relay #7 off)
Couldn't the 8 IF/THEN statements to turn on relays be reduced to something like HIGH B.b0 or HIGH B.#b0 ??? Wishful thinking Obviously these produce syntax errors. But certainly there is a better way then a zillion IF/THEN's .
And again the same for 8 IF/THEN statements to turn off relays, LOW B.b0 or LOW b.#b0
Famous quote (from me) "I bet it's simple, but sometimes simple is too hard for me".
Thanks in advance.
"Ham Radio Addict"