bits reader

hey out there,
I am making a project about a temperator reader. and the input i get to my arduino is in 4 bits, that come trough 4 fires that go high and low, and a connectet to A0, A1, A2, A3, which is the analog ports, (have used the digital ports to a LCD display). is there a way to arduino to read from them, with out me just saying "if (A0 & A1 & A3 == HIGH) { //then do something somthing}" whit every bit?

Board: Arduino Duemilanove w/ ATmega328

-David

Combine the individual bits into a single variable.

do you have a little exsempel of that? :slight_smile:

http://arduino.cc/en/Reference/BitWrite

does bit Bitwrite not just support if the bits come in at a singel port?, where mine comes in at 4 ports

Why not try it, just for a giggle?

lol it's a school project, so hoping i can make it work XD
idk have to write it propely

// define the bit input ports
int bitA = A0;
int bitB = A1;
int bitC = A2;
int bitD = A3;

void setup() {
// giving the inputs the bits valuer
bit(0) = bitA;
bit(1) = bitB;
bit(2) = bitC;
bit(3) = bitD;

// combine the bits in one string
char* stringbits[ ]={ bitA, bitB, BitC, bitD}

idk about the string, have not had that much about it yet

edit:: the bits is comming from a HT12D IC circles (if that helps)

Who said anything about a string?

bit(0) = bitA;

Assign a value to a function call?

idk about the string,

"idk"?

AWOL:
Who said anything about a string?

ow, have read that wrong sry :stuck_out_tongue:

sry

?

Have got irritable vowel syndrome or something?
Or is there something wrong with your keyboard?

sorry think its teenage chat syndrom

sry = sorry
idk = i don't know

with bit(0)=bitA
i was trying to assign input A0 to bit(0) A0 is called bitA for better understanding to my self

i was trying to assign input A0 to bit(0)

And "bit" is a function?

Why not just try playing around with bitWrite and a simple variable, and see if the values you print out (hint) match your expectations?

fundt it here http://arduino.cc/en/Reference/Bit

Returns

the value of the bit

(The underline is my emphasis)

ok. but do i not have to assign my 4 inputs to the diffrent bits, so arduino know what is what?

Yes, and that is where you use bitWrite if your binary arithmetic is shaky.

The great thing about the Arduino is that you could have tried all sorts of approaches in the hour or so you've wasted with this dialogue.

the one more question with bitWrite
can you explain in bit more detail what x,n,b is? the reference site does not do it that well.
so i can connect my 4 inputs to "A0 = 1" "A1 = 2" "A2 = 4" "A3 = 8" "input = bit"
bitwrite(x ,n ,b);

Parameters

x: the numeric variable to which to write

n: which bit of the number to write, starting at 0 for the least-significant (rightmost) bit

b: the value to write to the bit (0 or 1)

:drooling_face:
but white that i can only have one input

bitWrite (x, n);
x= analogRead(A0);
n= analogRead(A0);
that was the first input, but i have define the 3 other inputs aswell,