I want to assign input_x to an array. For example:
I have 8 sensors and I'll use b port on 18f4550 for reading their values 1 or 0.
I declare an array int array[8] in which I don't describe the values,
then I'm going to do array=input_b.
But it doesn't work. It says it needs an LVALUE.
Please, is it possible or not? If it is, where am I doing a mistake?
Thank you.
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
Posted: Thu Nov 01, 2012 9:57 am
OK. It is not very clear from your description, but I suspect you want to have an array of single bits containing the values from a port?.
If so, answer depends on the age of your compiler.
Code:
union {
int8 b;
int1 bits[8];
} port_bits;
port_bits.b=input_b();
//then port_bits.bits[0] to port_bits.bits[7] are the eight bits from the port
This is only supported on reasonably 'recent' compilers.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum