Go Down

### Topic: Help with LED VU Meter (Read 10608 times)previous topic - next topic

#### wally_z

#15
##### Aug 10, 2011, 10:31 pm
Quote

Simple binary arithmetic.
A one bit number can represent two states zero or one.
A two bit number can represent four states: 0, 1, 2, 3 (in binary 00, 01, 10, 11)
A three bit number can represent eight states 0, 1, 2, 3, 4, 5, 6, 7 (000, 001, 010, 011, 100, 101, 110, 111)

For every extra bit, double the number of states.

This is basic stuff, and pretty much essential that you understand

Now that you put it that way, it all makes perfect sense. Its so simple, and yet I couldn't see it. Thank you for explaining this, for it will help me out greatly in my future endeavors. So when there is the "10" in the code that could mean a 10 bit number such as 0001110001?

#### AWOL

#16
##### Aug 10, 2011, 10:32 pm
No, if you see decimal 10 in your code, it takes just four bits (1010) to represent in binary.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### wally_z

#17
##### Aug 10, 2011, 10:35 pm

No, if you see decimal 10 in your code, it takes just four bits (1010) to represent in binary.

Now it's getting confusing. So 1 in binary is 10? How does 2 numbers come from one number? I get how it's on and off but not really how 2 numbers come from 1 or 0. Could you maybe link me to a chart or something about this?

#### AWOL

#18
##### Aug 10, 2011, 10:39 pm
Quote
So 1 in binary is 10?

No, the great thing about 1 is that is only ever 1.
Think about the number 15 in decimal
What does the 1 represent?
It actually represents 10 decimal, and the 5 represents 5 times 1.

In binary (not decimal), each digit's position represents an increase not of ten decimal, but two.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### wally_z

#19
##### Aug 10, 2011, 10:41 pm

Quote
So 1 in binary is 10?

No, the great thing about 1 is that is only ever 1.
Think about the number 15 in decimal
What does the 1 represent?
It actually represents 10 decimal, and the 5 represents 5 times 1.

In binary (not decimal), each digit's position represents an increase not of ten decimal, but two.

Okay, 1 is always 1. Now for 15 the one is 1, and the 5 is 5 ones. So thats 111111?

#### AWOL

#20
##### Aug 10, 2011, 10:42 pm
Quote
Now for 15 the one is 1,

No, read it again - it is 1 * 10.

15 decimal is 1111 binary.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### wally_z

#21
##### Aug 10, 2011, 10:47 pm

Quote
Now for 15 the one is 1,

No, read it again - it is 1 * 10.

15 decimal is 1111 binary.

15      {1}   {111}
|         \
The one in 15  \
3*5?

How do you get three ones? Instead of having me try to figure it out can you PLEASE just explain?

Like this:
1=1
2=11?
3=111?
etc.

#### AWOL

#22
##### Aug 10, 2011, 10:50 pmLast Edit: Aug 10, 2011, 10:53 pm by AWOL Reason: 1
Quote

I'm trying to explain, but you're just batting questions back and not thinking.
Quote
1=1
2=11?
3=111?

That's unary (finger counting), not binary.
I've already written out the numbers 0..7 in binary:
000
001
010
011
100
101
110
111

Quote
How do you get three ones?

I didn't - count them again
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### wally_z

#23
##### Aug 10, 2011, 11:03 pm

Quote
1=1
2=11?
3=111?

That's unary (finger counting), not binary.
I've already written out the numbers 0..7 in binary:
000
001
010
011
100
101
110
111
Quote
How do you get three ones?

I didn't - count them again

So when counting up, you do this: (follow as I explain to myself)
000=0
001=1
and then move it over one digit to the left
010=2
then put the 1 in the third columb
011=3
then clear it and put a 1 in the first columb
100
then put the 1 I the third digit
...
I kinda get it now.
8=0000 (this doesn't seem right unless its supposed to be a 4 bit number i think)
9=0001
10=0010
11=0011
12=0100
13=0101
14=0111
15=1000?

ALTERNATE:
8=1000
9=1001
10=1010 (now I see, you have to go to the left to continue, EUREKA!!!!!!!)
11=1011
12=1100
13=1101
14=1110
15=1111!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

#### AWOL

#24
##### Aug 10, 2011, 11:05 pm
Bingo!
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### wally_z

#25
##### Aug 10, 2011, 11:06 pm
AWOL, thank you for teaching me to count in binary. I already knew how to use a binary clock (unrelated) and to count by 2 like for data such as 16, 32 bit, 64 bit, 128 bit (encryptions). I get it now.

#### wally_z

#26
##### Aug 10, 2011, 11:08 pm
Once you hit the number 32, things get fun.

#### wally_z

#27
##### Aug 10, 2011, 11:10 pm
I'm going to see how high I can count before I give up/get tired!

#### AWOL

#28
##### Aug 10, 2011, 11:12 pm
I've been doing it for so long, it is second-nature to me now, but in decimal, the weightings are
100 = 1
101 = 10
102 = 100
103 = 1000

in binary
20 = 1  (1 is always 1 remember?)
21 = 2
22 = 4
23 = 8

So, 15 decimal is 8 + 4 + 2 + 1, so 1111 in binary.
And 12 decimal is 8 + 4, so 1100 in binary.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### AWOL

#29
##### Aug 10, 2011, 11:13 pm
Quote
I'm going to see how high I can count before I give up/get tired!

You've got ten fingers - see if you can count to 1023.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Go Up