Go Down

Topic: I am new in this arduino, can someone help me? (Read 474 times) previous topic - next topic

Rytsu7

I am seeing this error in the code I used for 8x24 led matrix, it is possibe?


F:\Arduino\LEDMatrixSerial\LEDMatrixSerial.ino:159:33: warning: right shift count >= width of type

     digitalWrite(COL_24, (~b >> 23) & 0x01); // Get the 8th bit: 000000000000000000000001

                                 ^

exit status 1
'B111111111111111111111111' was not declared in this scope


I attached the code I used because I really don't know what to do about that void setColumn(byte..) area. THANK YOU SO MUCH FOR HELP!

AWOL

Use 0b instead of B.

Better still, use hex.


BTW, did you notice the post at the top of Introduction section where you posted this question, asking you NOT to post questions here?
"Pete, it's a fool (who) 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.

Rytsu7

I'm really sorry, I was to edit the post to ask for moving. Thank you so much. so instead of using B's in front of the bytes, i should use 0b? sorry, i'm really new to this coding thing.

AWOL

We post "how to use the forum" topics.
It's useful to read them, before posting.
"Pete, it's a fool (who) 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.

Rytsu7

I'm really sorry about that. I really don't know where to put 0b's for the program to be verified. Can you please tell me how to use those? Thank you so much

AWOL

I can't really tell you without seeing your code.
In code tags.
"Pete, it's a fool (who) 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.

aarg

#6
Dec 15, 2017, 10:58 pm Last Edit: Dec 15, 2017, 11:01 pm by aarg
Arduino uses a cheesy defs file to simulate a native numeric type specifier like "0x", with the "B" prefix. So you can't exceed the 8 bits that is defined in it. You have used 16.

You will need to use something like
Code: [Select]
const int COL_24 = 0xFFFF;
instead of
Code: [Select]
const int COL_24 = B111111111111111111111111;
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Rytsu7

Does that mean that in,

"void setColumns(byte b) {
    digitalWrite(COL_1, (~b >> 0) & 0x01); // Get the 1st bit:   100000000000000000000000
    digitalWrite(COL_2, (~b >> 1) & 0x01); // Get the 2nd bit:   010000000000000000000000
    digitalWrite(COL_3, (~b >> 2) & 0x01); // Get the 3rd bit:   001000000000000000000000
    digitalWrite(COL_4, (~b >> 3) & 0x01); // Get the 4th bit:   000100000000000000000000
    digitalWrite(COL_5, (~b >> 4) & 0x01); // Get the 5th bit:   000010000000000000000000
    digitalWrite(COL_6, (~b >> 5) & 0x01); // Get the 6th bit:   000001000000000000000000
    digitalWrite(COL_7, (~b >> 6) & 0x01); // Get the 7th bit:   000000100000000000000000
    digitalWrite(COL_8, (~b >> 7) & 0x01); // Get the 8th bit:   000000010000000000000000
    digitalWrite(COL_9, (~b >> 8) & 0x01); // Get the 8th bit:   000000001000000000000000
    digitalWrite(COL_10, (~b >> 9) & 0x01); // Get the 8th bit:  000000000100000000000000
    digitalWrite(COL_11, (~b >> 10) & 0x01); // Get the 8th bit: 000000000010000000000000
    digitalWrite(COL_12, (~b >> 11) & 0x01); // Get the 8th bit: 000000000001000000000000
    digitalWrite(COL_13, (~b >> 12) & 0x01); // Get the 8th bit: 000000000000100000000000
    digitalWrite(COL_14, (~b >> 13) & 0x01); // Get the 8th bit: 000000000000010000000000
    digitalWrite(COL_15, (~b >> 14) & 0x01); // Get the 8th bit: 000000000000001000000000
    digitalWrite(COL_16, (~b >> 15) & 0x01); // Get the 8th bit: 000000000000000100000000
    digitalWrite(COL_17, (~b >> 16) & 0x01); // Get the 8th bit: 000000000000000010000000
    digitalWrite(COL_18, (~b >> 17) & 0x01); // Get the 8th bit: 000000000000000001000000
    digitalWrite(COL_19, (~b >> 18) & 0x01); // Get the 8th bit: 000000000000000000100000
    digitalWrite(COL_20, (~b >> 19) & 0x01); // Get the 8th bit: 000000000000000000010000
    digitalWrite(COL_21, (~b >> 20) & 0x01); // Get the 8th bit: 000000000000000000001000
    digitalWrite(COL_22, (~b >> 21) & 0x01); // Get the 8th bit: 000000000000000000000100
    digitalWrite(COL_23, (~b >> 22) & 0x01); // Get the 8th bit: 000000000000000000000010
    digitalWrite(COL_24, (~b >> 23) & 0x01); // Get the 8th bit: 000000000000000000000001
;"

after the 16th bit, i would change the ~b>> n to ~b>> 0x...... ? I am really sorry for this I am really not familiar with codings and stuff, thank you so much for the answers

Rytsu7

byte E[8] = {0x3C,0x20,0x20,0x3C,0x20,0x20,0x20,0x3C};
byte L[8] = {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3E};
byte C[8] = {0x1C,0x20,0x20,0x20,0x20,0x20,0x20,0x1C};
byte T[8] = {0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10};
byte R[8] = {0x38,0x24,0x24,0x28,0x30,0x28,0x24,0x24};
byte O[8] = {0x1C,0x22,0x22,0x22,0x22,0x22,0x22,0x1C};
byte N[8] = {0x42,0x62,0x52,0x52,0x4A,0x46,0x46,0x42};
byte I[8] = {0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x38};
byte S[8] = {0x1C,0x20,0x20,0x10,0x08,0x04,0x04,0x38};
byte H[8] = {0x22,0x22,0x22,0x3E,0x22,0x22,0x22,0x22};
byte U[8] = {0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x1C,};
byte B[8] = {0x38,0x24,0x24,0x38,0x38,0x24,0x24,0x38};
byte smile[8]=   {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C};
byte neutral[8]= {0x3C,0x42,0xA5,0x81,0xBD,0x81,0x42,0x3C};
byte frown[8]=   {0x3C,0x42,0xA5,0x81,0x99,0xA5,0x42,0x3C};

can i use codes like this?
if so, how can i declare them? Thank you so much!

TomGeorge

#9
Dec 16, 2017, 08:12 am Last Edit: Dec 16, 2017, 08:13 am by TomGeorge
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please tell us your electronics, programming, Arduino, hardware experience?

What is you code supposed to do?
What is the application?
What model Arduino are you using?

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

Rytsu7

Thank you so much for your response, I am really sorry about the post.

I am still a student, doesn't know much about programming, and has the arduino mega at2560

The code is supposed to display changing patterns in the 8x24 led matrix within the loop
I am using the Arduino MegaAT2560

Thank you so much.


TomGeorge

Hi,
Have you got your code working?

If so can you post it please.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

Rytsu7

No, this code is a project here that I copied and tried to modified for 8x24 because it is originally for 8x8 matrix.

Code: [Select]
//code write by Moz for YouTube changel LogMaker360, 12-11-2015
//code belongs to this video:
// Pins
// Fill in the pins you used on your own setup.
// WARNING: Make sure you have resistors connected between the rows and the arduino.

#define ROW_1 22
#define ROW_2 23
#define ROW_3 24
#define ROW_4 25
#define ROW_5 26
#define ROW_6 27
#define ROW_7 28
#define ROW_8 29

#define COL_1 37
#define COL_2 36
#define COL_3 35
#define COL_4 34
#define COL_5 33
#define COL_6 32
#define COL_7 31
#define COL_8 30
#define COL_9 38
#define COL_10 39
#define COL_11 40
#define COL_12 41
#define COL_13 42
#define COL_14 43
#define COL_15 44
#define COL_16 45
#define COL_17 46
#define COL_18 47
#define COL_19 48
#define COL_20 49
#define COL_21 50
#define COL_22 51
#define COL_23 52
#define COL_24 53

const byte rows[] = {
    ROW_1, ROW_2, ROW_3, ROW_4, ROW_5, ROW_6, ROW_7, ROW_8
};

// The display buffer
// It's prefilled with a smiling face (1 = ON, 0 = OFF)
byte slow[] =
{B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111};
byte off[] =
{B000000000000000000000000,
 B000000000000000000000000,
 B000000000000000000000000,
 B000000000000000000000000,
 B000000000000000000000000,
 B000000000000000000000000,
 B000000000000000000000000,
 B000000000000000000000000};
byte angry[] =
{B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111,
 B111111111111111111111111};

float timeCount = 0;

void setup() {
    // Open serial port
    Serial.begin(9600);
   
    // Set all used pins to OUTPUT
    // This is very important! If the pins are set to input
    // the display will be very dim.
    for (byte i = 22; i <= 53; i++)
        pinMode(i, OUTPUT);
}

void loop() {
  // This could be rewritten to not use a delay, which would make it appear brighter
timeCount += 1;
if(timeCount <  50) {
drawScreen(off);
} else if (timeCount < 100 ) {
// do nothing
} else if (timeCount <  150) {
drawScreen(slow);
} else if (timeCount <  430) {
// nothing
} else if (timeCount <  600) {
drawScreen(off);
} else if (timeCount <  630) {
// nothing
} else if (timeCount <  800) {
drawScreen(angry);
} else if (timeCount <  830) {
// nothing
} else if (timeCount <  1000) {
drawScreen(slow);
} else if (timeCount <  1030) {
// nothing
} else if (timeCount <  1200) {
drawScreen(angry);
} else if (timeCount <  1230) {
// nothing
} else {
// back to the start
timeCount = 0;
}
}
 void  drawScreen(byte buffer2[]){
     
   
   // Turn on each row in series
    for (byte i = 0; i < 23; i++) {
        setColumns(buffer2[i]); // Set columns for this specific row
       
        digitalWrite(rows[i],HIGH);
        delay(2); // Set this to 50 or 100 if you want to see the multiplexing effect!
        digitalWrite(rows[i], LOW);
       
    }
}


void setColumns(byte b) {
    digitalWrite(COL_1, (~b >> 0) & 0x01); // Get the 1st bit:   100000000000000000000000
    digitalWrite(COL_2, (~b >> 1) & 0x01); // Get the 2nd bit:   010000000000000000000000
    digitalWrite(COL_3, (~b >> 2) & 0x01); // Get the 3rd bit:   001000000000000000000000
    digitalWrite(COL_4, (~b >> 3) & 0x01); // Get the 4th bit:   000100000000000000000000
    digitalWrite(COL_5, (~b >> 4) & 0x01); // Get the 5th bit:   000010000000000000000000
    digitalWrite(COL_6, (~b >> 5) & 0x01); // Get the 6th bit:   000001000000000000000000
    digitalWrite(COL_7, (~b >> 6) & 0x01); // Get the 7th bit:   000000100000000000000000
    digitalWrite(COL_8, (~b >> 7) & 0x01); // Get the 8th bit:   000000010000000000000000
    digitalWrite(COL_9, (~b >> 8) & 0x01); // Get the 8th bit:   000000001000000000000000
    digitalWrite(COL_10, (~b >> 9) & 0x01); // Get the 8th bit:  000000000100000000000000
    digitalWrite(COL_11, (~b >> 10) & 0x01); // Get the 8th bit: 000000000010000000000000
    digitalWrite(COL_12, (~b >> 11) & 0x01); // Get the 8th bit: 000000000001000000000000
    digitalWrite(COL_13, (~b >> 12) & 0x01); // Get the 8th bit: 000000000000100000000000
    digitalWrite(COL_14, (~b >> 13) & 0x01); // Get the 8th bit: 000000000000010000000000
    digitalWrite(COL_15, (~b >> 14) & 0x01); // Get the 8th bit: 000000000000001000000000
    digitalWrite(COL_16, (~b >> 15) & 0x01); // Get the 8th bit: 000000000000000100000000
    digitalWrite(COL_17, (~b >> 16) & 0xff); // Get the 8th bit: 000000000000000010000000
    digitalWrite(COL_18, (~b >> 17) & 0xff); // Get the 8th bit: 000000000000000001000000
    digitalWrite(COL_19, (~b >> 18) & 0xff); // Get the 8th bit: 000000000000000000100000
    digitalWrite(COL_20, (~b >> 19) & 0xff); // Get the 8th bit: 000000000000000000010000
    digitalWrite(COL_21, (~b >> 20) & 0xff); // Get the 8th bit: 000000000000000000001000
    digitalWrite(COL_22, (~b >> 21) & 0xff); // Get the 8th bit: 000000000000000000000100
    digitalWrite(COL_23, (~b >> 22) & 0xff); // Get the 8th bit: 000000000000000000000010
    digitalWrite(COL_24, (~b >> 23) & 0xff); // Get the 8th bit: 000000000000000000000001
   
   
}


it is the part of the void setColumns that I cannot understand, I think I have to put their bits in the sprites or patterns but the error, "'B11111111111111111' was not declared in this scope" appears.

thank you!

TomGeorge

Everything runs on smoke, let the smoke out, it stops running....

Rytsu7

#14
Dec 16, 2017, 04:11 pm Last Edit: Dec 16, 2017, 05:54 pm by Rytsu7
I think all the LED's cathode are all connected vertically, and connected to an arduino pins. I am sorry if it's poorly made.

I am using 32 pins in the arduino for the 8x24 matrix.

edit:

I tried to verify this code:

Code: [Select]
//code write by Moz for YouTube changel LogMaker360, 12-11-2015
//code belongs to this video:
// Pins
// Fill in the pins you used on your own setup.
// WARNING: Make sure you have resistors connected between the rows and the arduino.

#define ROW_1 22
#define ROW_2 23
#define ROW_3 24
#define ROW_4 25
#define ROW_5 26
#define ROW_6 27
#define ROW_7 28
#define ROW_8 29

#define COL_1 37
#define COL_2 36
#define COL_3 35
#define COL_4 34
#define COL_5 33
#define COL_6 32
#define COL_7 31
#define COL_8 30
#define COL_9 38
#define COL_10 39
#define COL_11 40
#define COL_12 41
#define COL_13 42
#define COL_14 43
#define COL_15 44
#define COL_16 45
#define COL_17 46
#define COL_18 47
#define COL_19 48
#define COL_20 49
#define COL_21 50
#define COL_22 51
#define COL_23 52
#define COL_24 53

const byte rows[] = {
    ROW_1, ROW_2, ROW_3, ROW_4, ROW_5, ROW_6, ROW_7, ROW_8
};

byte slow[] =
{0xfffff,
 0xfffff,
 0xfffff,
 0xfffff,
 0xfffff,
 0xfffff,
 0xfffff,
 0xfffff};
byte off[] =
{0x0,
 0x0,
 0x0,
 0x0,
 0x0,
 0x0,
 0x0,
 0x0};
byte angry[] =
{0xfffff,
 0xfffff,
 0xfffff,
 0xfffff,
 0xfffff,
 0xfffff,
 0xfffff,
 0xfffff};

float timeCount = 0;

void setup() {
    // Open serial port
    Serial.begin(9600);
    
    // Set all used pins to OUTPUT
    // This is very important! If the pins are set to input
    // the display will be very dim.
    for (byte i = 22; i <= 53; i++)
        pinMode(i, OUTPUT);
}

void loop() {
  // This could be rewritten to not use a delay, which would make it appear brighter
timeCount += 1;
if(timeCount <  50) {
drawScreen(off);
} else if (timeCount < 100 ) {
// do nothing
} else if (timeCount <  150) {
drawScreen(slow);
} else if (timeCount <  430) {
// nothing
} else if (timeCount <  600) {
drawScreen(off);
} else if (timeCount <  630) {
// nothing
} else if (timeCount <  800) {
drawScreen(angry);
} else if (timeCount <  830) {
// nothing
} else if (timeCount <  1000) {
drawScreen(slow);
} else if (timeCount <  1030) {
// nothing
} else if (timeCount <  1200) {
drawScreen(angry);
} else if (timeCount <  1230) {
// nothing
} else {
// back to the start
timeCount = 0;
}
}
 void  drawScreen(byte buffer2[]){
    
    
   // Turn on each row in series
    for (byte i = 0; i < 23; i++) {
        setColumns(buffer2[i]); // Set columns for this specific row
        
        digitalWrite(rows[i],HIGH);
        delay(2); // Set this to 50 or 100 if you want to see the multiplexing effect!
        digitalWrite(rows[i], LOW);
        
    }
}


void setColumns(byte b) {
    digitalWrite(COL_1, (~b >> 0) & 0x80000);
    digitalWrite(COL_2, (~b >> 1) & 0x80000);
    digitalWrite(COL_3, (~b >> 2) & 0x80000);
    digitalWrite(COL_4, (~b >> 3) & 0x80000);
    digitalWrite(COL_5, (~b >> 4) & 0x80000);
    digitalWrite(COL_6, (~b >> 5) & 0x80000);
    digitalWrite(COL_7, (~b >> 6) & 0x80000);
    digitalWrite(COL_8, (~b >> 7) & 0x80000);
    digitalWrite(COL_9, (~b >> 8) & 0x80000);  
    digitalWrite(COL_10, (~b >> 9) & 0x80000);
    digitalWrite(COL_11, (~b >> 10) & 0x80000);
    digitalWrite(COL_12, (~b >> 11) & 0x80000);
    digitalWrite(COL_13, (~b >> 12) & 0x80000);
    digitalWrite(COL_14, (~b >> 13) & 0x80000);  
    digitalWrite(COL_15, (~b >> 14) & 0x80000);  
    digitalWrite(COL_16, (~b >> 15) & 0x80000);
    digitalWrite(COL_17, (~b >> 16) & 0x80000);  
    digitalWrite(COL_18, (~b >> 17) & 0x80000);  
    digitalWrite(COL_19, (~b >> 18) & 0x80000);  
    digitalWrite(COL_20, (~b >> 19) & 0x80000);  
    digitalWrite(COL_21, (~b >> 20) & 0x80000);  
    digitalWrite(COL_22, (~b >> 21) & 0x80000);  
    digitalWrite(COL_23, (~b >> 22) & 0x80000);  
    digitalWrite(COL_24, (~b >> 23) & 0x80000);  
    
    // If the polarity of your matrix is the opposite of mine
    // remove all the '~' above.
}


The leds light up but doesn't do the loop. What should I do to make the byte/patterns appear from the loop?

Thank you so much!

Go Up