Hi jefftee, d_stranz,
Yes, the main goal of this program is to send this variables via message (ROS) to Arduino.
I'm sorry, I forgot to post my globals.h file, that's where I initialize my global variables:
#ifndef GLOBALS_H
#define GLOBALS_H
extern int numberOfMotors;
extern int intensidade[16];
extern int local[16];
#endif // GLOBALS_H
#ifndef GLOBALS_H
#define GLOBALS_H
extern int numberOfMotors;
extern int intensidade[16];
extern int local[16];
#endif // GLOBALS_H
To copy to clipboard, switch view to plain text mode
As you can imagine I am very new in this C++ thing, I've only used arduino and C, so that's why I jumped right away to the global variables.
I declared another namespace (global2) because when i tried to use the global namespace that I created in the other window it said that that namespace was already used (or something like that
). I thought I didnt even need to create that namespace because the variables should already be declared in the globals.h, however, if I only do numberOfMotors = 5 for example (I'm sorry if I'm saying something stupid), then I get an error saying that numberOfMotors doesnt name a type.
Instead of using global variables should I try to use classes? The reason I tried to escape from it is that I'm not very sure how the all classes thing work, and I didn't want to mess things up even more than they already are.
Thank you for the answers!! 
Added after 14 minutes:
Yup, I'm very very noob on this.
Turns out I only needed to initialize in my mainwindow.cpp the following
int numberOfMotors;
int intensidade[16];
int local[16];
int numberOfMotors;
int intensidade[16];
int local[16];
To copy to clipboard, switch view to plain text mode
and
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
numberOfMotors =5;
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
numberOfMotors =5;
}
To copy to clipboard, switch view to plain text mode
and in my main.cpp I just did
cout << "exp " << numberOfMotors << endl;
cout << "exp " << numberOfMotors << endl;
To copy to clipboard, switch view to plain text mode
without initializing anything and it printed 5.
Now the thing is, it only prints once and i wanted it to constantly print it everytime I update something. I guess now it has to do with what jefftee said first..
Bookmarks