Questions tagged [variables]
Variables are used to store data in a sketch/program.
16 questions
14
votes
5
answers
82k
views
How to retrieve the data type of a variable?
I am using Arduino and I would like to know if there is a function that returns the data type of a variable. That is, I would like to run something as like the following:
// Note: 'typeof' is a ...
7
votes
2
answers
3k
views
Can you use Serial Port as a variable?
I am doing a project where, for troubleshooting reasons, I find myself often swapping components to different serial ports. Maybe one time it's in Serial, then in Serial1, maybe I need to try if ...
0
votes
2
answers
155
views
What is the opposite of this data operation?
If I store in an array a double-value in this format, in which format I should be able to read the same double out?
double myDouble = 12.123456;
byte myArray[] = {0x00, 0x00, 0x00, 0x00};
myArray[0] ...
6
votes
1
answer
3k
views
What are the benfits of global variables over static class members?
On an embedded system we use global variables often to keep dynamic memory consumption on heap and stack low. But global variables are also considered bad programming practice if they aren't used in a ...
2
votes
2
answers
1k
views
How to write nonblocking code, for polling sensor at 100 Hz
I'm using this piece of code to try to poll an IMU sensor at 100 Hz (for a AHRS sensor fusion library).
void loop(void)
{
// nonblocking code variables
static uint32_t last_ms;
uint32_t ms;
// ...
1
vote
1
answer
3k
views
Avoid global variables with classes
I want to avoid global variables when using my own classes in Arduino. Here is a example.
void setup(){
/* setup here */
classA objectA;
}
void loop(){
objectA.someMethod();
}
I know that my ...
0
votes
1
answer
980
views
Global Variable does not Change when Value is set within Boolean Function
I have a boolean function which contains a string. In my main project this string is extracted from a website using an ESP8266 which is compatible with the Arduino IDE. I need to convert this string ...
0
votes
2
answers
917
views
How can I move these global variables to be
I'm taking a sample I found on the web about how to get ROS and arduino to communicated together over serial. I have the sample working and now I'm moving the idea of the sample into my OOP project ...