Go Down

Topic: 3by3 led cube control by matrix not working (Read 1 time) previous topic - next topic

AWOL

Quote
111000000,
011100000,
001110000,

Why are some constants in decimal, and others in octal?
"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.

zer044


Quote
111000000,
011100000,
001110000,

Why are some constants in decimal, and others in octal?


Umm... I have no idea what you are talking about so i guess i got some reading to do.

What i was trying to achieve is each line represents a level on my cube each 1 or 0 represents the led in that levels status.
so "011100000" represents 1st led off second on third on fourth on... ect..

AWOL

Quote
so "011100000" represents 1st led off second on third on fourth on... ect.

In C, a constant starting with a zero is taken to be an octal value, in this case, the equivalent decimal value is 2 392 064.

If you want a binary constant, prefix the number with "0b".
"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.

zer044


Quote
so "011100000" represents 1st led off second on third on fourth on... ect.

In C, a constant starting with a zero is taken to be an octal value, in this case, the equivalent decimal value is 2 392 064.

If you want a binary constant, prefix the number with "0b".


I just realized what i was doing wrong with my original code..... 
i declared my array wrong
Code: [Select]
int first[3][9] = {
111000000,
011100000,
001110000,
};


Should have been ...
Code: [Select]
int first[3][9] = {
{1, 1, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0, 0, 0},
};


if i want declare them as bytes i should do this?
Code: [Select]
int first[3]= {
0b111000000,
0b011100000,
0b001110000,
};


do i have to change the array type to byte? also i tried this method but used the "B" prefix and it only let me use upto 8 numbers.. i have 9 leds so thats a problem.


AWOL

#9
Aug 26, 2011, 07:12 pm Last Edit: Aug 26, 2011, 07:18 pm by AWOL Reason: 1
Quote
used the "B" prefix and it only let me use upto 8 numbers

If you need 9 bits, use "0b" as the prefix.
See reply #7.
The "B" prefix is an Arduino convenience.
"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.

Go Up