Questions tagged [variables]

Variables are used to store data in a sketch/program.

Filter by
Sorted by
Tagged with
8
votes
2answers
30k 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 ...
8
votes
2answers
3k views

How to update a variable in an ISR using Timers

I'm trying to check the frequency of Timer3 using a counter. The value of the counter, declared as volatile, is incremented in the ISR and every second the sum is shown in the main loop and the value ...
2
votes
2answers
729 views

Why declare analog pins as ints?

I often see code like this: const int piezo = A0; const int sensorPin = A1; From my understanding, an int variable can hold things like -123, 0, 1, 456, etc. How can A0 or A1 be an int?
0
votes
2answers
106 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] ...
18
votes
4answers
137k views

How can I declare an array of variable size (Globally)

I'd like to make three arrays of the same length. According to the documentation, Arrays must be defined as int myArray[10]; where 10 can be substituted for a known length (another integer), or filled ...
6
votes
1answer
2k 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 ...
4
votes
2answers
832 views

Locally declared variable takes up global variable space in dynamic memory/SRAM

I'm trying to make my Arduino Uno control the air conditioner by recording the raw IR signal of several of the AC remotes temperatures using AnalysisIR. However these IR codes are quite long (array ...
1
vote
1answer
2k 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 ...
1
vote
2answers
503 views

Append Text to Variable Names: Please Help Me Shorten This Code

I'm trying to shorten the code under "setup" below, where I have over 120 variables that are being read from an external EEPROM. There is a pattern where the variable that stores the position of the ...
0
votes
3answers
5k views

Pass variable in a URL

I am working on code where I am able to manually enter the value in the URL to let the PHP code save it in the database, but I'm unsure how to do it with a variable in a loop running. This is the URL: ...
0
votes
0answers
77 views

Passing variable in url [duplicate]

Working on a arduino script where I am right now entering manually the value with the URL, but wondering how to do it with a int in a loop. This is the url and how it works now: student.cs.hioa.no/~...
0
votes
2answers
634 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 ...
0
votes
2answers
5k views

When to use different variable types? [closed]

There are several different types in the Arduino programming language. They each have different applications that can use up the limited RAM in the Arduino. When should i use each?