Relay Address

Hi all
how can I find the relay addres from this
dec hex
90 5A Get software version - transmits a single byte back to the controller containing the software revision
91 5B
Get relay states - transmits a single byte back to the controller, bit high meaning the corresponding relay is powered

92 5C Set relay states - the next byte sent to the command register will set all relay states, All on = 255 (11111111) All off = 0
100 64 All relays on
101 65 Turn relay 1 on
102 66 Turn relay 2 on
103 67 Turn relay 3 on
104 68 Turn relay 4 on
105 69 Turn relay 5 on
106 6A Turn relay 6 on
107 6B Turn relay 7 on
108 6C Turn relay 8 on
110 6E All relays off
111 6F Turn relay 1 off
112 70 Turn relay 2 off
113 71 Turn relay 3 off
114 72 Turn relay 4 off
115 73 Turn relay 5 off
116 74 Turn relay 6 off
117 75 Turn relay 7 off
118 76 Turn relay 8 off
160 A0 1st byte in sequence to change serial address
165 A5 3rd byte in sequence to change serial address
170 AA 2nd byte in sequence to change serial address

am using this sketch to control the serial but cant find what the relay address is
void setup(){
Serial.begin(9600);
}

void loop(){
Serial.print(relay_address, BYTE); // send relay module address
Serial.print(100, BYTE); // All relays on

Serial.print(relay_address, BYTE); // send relay module address
Serial.print(101, BYTE); // Turn relay 1 on

//etc

Serial.print(relay_address, BYTE); // send relay module address
Serial.print(110, BYTE); //All relays off

Serial.print(relay_address, BYTE); // send relay module address
Serial.print(111, BYTE); //Turn relay 1 off
//etc
}
stumped at the moment as i don't fully understand serial but getting there.

Thanks in anticipation Jon

hi Jon

I think you might have gotten your answer in another thread, but if not...

you need to delare the byte variable "relay_address" from the code above like this

byte relay_ address =
// put in the actual relay address after the equal sign (look in datasheet)

Then to control ther Devantech board, you just do two things:

  • open a serial conection at the appropriate speed, and
  • send the comand you want to execute.

For example, to turn on relay 7, send

Serial.print(relay_address, BYTE); // send relay module address
Serial.print(107, BYTE);

try to get just one command going at first...

D

Thank you Daniel will try that I am going one step at a time thanks again .

Jon