system
January 16, 2014, 8:44am
1
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
system
January 16, 2014, 9:01am
2
Combine the individual bits into a single variable.
system
January 16, 2014, 9:07am
3
do you have a little exsempel of that?
system
January 16, 2014, 9:11am
4
system
January 16, 2014, 9:39am
5
does bit Bitwrite not just support if the bits come in at a singel port?, where mine comes in at 4 ports
system
January 16, 2014, 9:44am
6
Why not try it, just for a giggle?
system
January 16, 2014, 10:12am
7
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)
system
January 16, 2014, 10:15am
8
Who said anything about a string?
bit(0) = bitA;
Assign a value to a function call?
idk about the string,
"idk"?
system
January 16, 2014, 10:21am
9
AWOL:
Who said anything about a string?
ow, have read that wrong sry
system
January 16, 2014, 10:23am
10
sry
?
Have got irritable vowel syndrome or something?
Or is there something wrong with your keyboard?
system
January 16, 2014, 10:30am
11
sorry think its teenage chat syndrom
sry = sorry
idk = i don't know
system
January 16, 2014, 10:46am
12
with bit(0)=bitA
i was trying to assign input A0 to bit(0) A0 is called bitA for better understanding to my self
system
January 16, 2014, 10:48am
13
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?
system
January 16, 2014, 10:49am
14
system
January 16, 2014, 10:50am
15
Returns
the value of the bit
(The underline is my emphasis)
system
January 16, 2014, 10:54am
16
ok. but do i not have to assign my 4 inputs to the diffrent bits, so arduino know what is what?
system
January 16, 2014, 11:03am
17
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.
system
January 16, 2014, 11:30am
18
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);
system
January 16, 2014, 11:45am
20
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,