Hello,
I have two sets of relays, each one have 8 outputs. Then let's say I need 16 bits to control all of them if working with 2 bytes.
I also have 16 sensors to be read and send status to B4A app.
I intend to create one package to write (sensors status) from Arduino B4R and decode it on B4A in bit structure, only to presente status on the app screen. Also I'll need to write from B4A (buttons on screen) to B4R creating the same bit structure to activate the relays.
What is the correct way to make it in "udp.write" structure? If there is any other way to work with this please let me know.
For example:
"00000000" Byte 1
Bit 0 -Sensor 10
Bit 1 -Sensor 11
Bit 2 -Sensor 12
...
Bit 7 - Sensor7
"00000000" Byte 2
Bit 0 -Sensor 20
Bit 1 -Sensor 21
Bit 2 -Sensor 22
...
Bit 7 - Sensor7
WRITE SENSOR STATUS FROM B4R TO B4A
B4R
How could be done in B4R side to send a bit structure to B4A?
udp.Write("0000000000000000".GetBytes)
udp.SendPacket
B4A
How could be done in B4A side to decode information received from B4R?
WRITE BUTTON COMMAND FROM B4A TO B4R
Same.
*I'm working with Arduino Mega 2560
I have two sets of relays, each one have 8 outputs. Then let's say I need 16 bits to control all of them if working with 2 bytes.
I also have 16 sensors to be read and send status to B4A app.
I intend to create one package to write (sensors status) from Arduino B4R and decode it on B4A in bit structure, only to presente status on the app screen. Also I'll need to write from B4A (buttons on screen) to B4R creating the same bit structure to activate the relays.
What is the correct way to make it in "udp.write" structure? If there is any other way to work with this please let me know.
For example:
"00000000" Byte 1
Bit 0 -Sensor 10
Bit 1 -Sensor 11
Bit 2 -Sensor 12
...
Bit 7 - Sensor7
"00000000" Byte 2
Bit 0 -Sensor 20
Bit 1 -Sensor 21
Bit 2 -Sensor 22
...
Bit 7 - Sensor7
WRITE SENSOR STATUS FROM B4R TO B4A
B4R
How could be done in B4R side to send a bit structure to B4A?
udp.Write("0000000000000000".GetBytes)
udp.SendPacket
B4A
How could be done in B4A side to decode information received from B4R?
WRITE BUTTON COMMAND FROM B4A TO B4R
Same.
*I'm working with Arduino Mega 2560
Last edited: