Pages: 1 [2] 3 4   Go Down
Author Topic: Help with LED VU Meter  (Read 3496 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25848
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25848
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

"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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25848
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Now for 15 the one is 1,
No, read it again - it is 1 * 10.

15 decimal is 1111 binary.
Logged

"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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25848
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
can you PLEASE just explain?
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
« Last Edit: August 10, 2011, 03:53:19 pm by AWOL » Logged

"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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25848
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bingo!
Logged

"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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Once you hit the number 32, things get fun.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm going to see how high I can count before I give up/get tired!
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25848
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25848
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Pages: 1 [2] 3 4   Go Up
Jump to: