Hello I need to transfer an array containing 8 bits ( 10110100 for example bytes ) by inserting it in a single byte the value 180. The transferred data when it is received I have to convert it back into individual bits maybe within an Array.
If you mean that the source array contains 8 bytes, each representing a bit then I suppose the first question I would have is why not hold those 8 bits in a single byte in the first place ?
You still haven't answered the question of how the 0's and 1's are defined in your program. Can't really answer without knowing that.
As you wrote it there's no conversion necessary. The number is stored as the same 8bits whether you want it represented as decimal or binary or hex it doesn't matter.
Do you have an array of 8 byte variables? Or an array of int? Or are they characters that need to convert from ASCII?
Even with this fix the result will be wrong because the SETBIT() can be only used for set bit to 1 and not to 0. It is not as @buckfast_beekeeper used it.
I basically have 8 on/off buttons. I need to transfer a byte data to another device where there are relays. Unfortunately I have so many groups of 8 buttons and I have to find a way to transfer this data with a few bytes.
The on/off 0/1 false/true data is on a bool variable. Or on a bool array.