Questions tagged [variables]
Variables are used to store data in a sketch/program.
162 questions
-2
votes
1
answer
81
views
How do I change what variable I am changing based on a separate number?
I am trying to change thing2 if I input 0, and thing3 if I input 1. I don't want to just have if/else to determine if I should be changing thing2 or thing3 because I want this to be more dynamic than ...
-1
votes
1
answer
949
views
Multiple definition error in STM32CubeIDE
How do global variable declarations work?
For example:
In file1.c I am defining:
#define volt_add 0x20
uint8_t vol[8]= {0x53, 0x35, 0x05, 0x22, volt_add,0x00,0x00,0x00};
uint16_t EM_vol;
I need to ...
0
votes
1
answer
1k
views
how to "skip" one parameter of a method with a default value letting it use it's default value, but change parameters after it [closed]
lets say we have a function like this(fictional):
function1(int Z, int X, bool Y=true, int Count=10, int ID=1,bool TeaTime=false);
And I want to run this function, but I want to change all parameters,...
1
vote
1
answer
280
views
Conditional assignment of array
I have some really long global variable arrays filled with data.
There is a single function that processes the data. The function works on only one array everytime. This arrays value changes every ...
0
votes
1
answer
94
views
Wrong use of memory?
Probably I'm doing something wrong.
I'm writing an Arduino sketch for ESP32.
Among the others I have this function:
#define HDR_MAX_LENGHT 4
#define CMD_MAX_LENGHT 5
#define ARG_MAX_LENGHT 5
#define ...
0
votes
1
answer
85
views
Inconsistent behavior of include statements?
This question deals with fonts. Well, actually, singular include files with constants that form bitmap fonts or images for LCD or OLED displays, such as this one: https://github.com/ThingPulse/esp8266-...
1
vote
1
answer
446
views
1 global variable consuming 19% of memory
I am working on a simple project on talking to the serial monitor, and my only global variable ("int" type, named "incomingByte") is consuming a lot of memory. There is no problem ...
2
votes
1
answer
3k
views
Space taken by Global Variables
Using Nano's for small programmes I get compilation reports about the amount of space taken by global variables.
On a typical progamme it says something like Sketch uses 16316 bytes (53%) of program ...
2
votes
1
answer
361
views
Global Variable not updating…
I'm building a small project to maintain a copper plating tank's temperature and filter pump duty cycle. I'm using the Adafruit Feather platform to hold an 8 segment matrix coupled with a Teensy 3.2 (...
-1
votes
1
answer
156
views
How to deal with global variables in a program which has more than 5 functions and every function accesses them without any problem? [duplicate]
I know that using Global Variables in programming may create lots of problems in long term , like , Bugs , Lags and more . I am working on a program which has more than 5 functions which need to ...
1
vote
0
answers
118
views
Why does this piece of code overflow at 255?
Im having a problem where i got unsinged long variable and i need to increment it in eeprom everytime setup starts and it overflows at 255 back to 0.
unsigned long NumberOfBoots = 0UL;
#define ...
1
vote
2
answers
993
views
How to reset a variable just before entering a function? [closed]
I am facing a problem where the if condition in the function waterNowrun is able to execute once after the program starts as the variable v is 0 at the start, but upon starting it again the if does ...
0
votes
2
answers
411
views
why can Arduino variables of int type contain a value such as A2
How come the following statement is true:
int inputPin = A2;
I thought int variables can only hold integer numbers. Is the A just a representation of a number?
Thanks for any help
1
vote
1
answer
952
views
using a variable to index an array
I'm using the keypad library to return a number 1-9. (im fairly sure this returns an int)
I have an array (data) showing the state of each button press.
so i would like the number returned by the ...
1
vote
0
answers
1k
views
Nextion won't update text using data passed in Arduino Uno serial print
Q: Is it possible to send data in variables from Arduino to Nextion through SerialPrint? If so, what is the correct syntax?
I have an Arduino Uno connected to a Nextion NX4024T032 and a Sunfounder ...
1
vote
3
answers
173
views
variable name standards, e.g best method to send motion_detect=true
I am working with some sensors and sending data to a public web server via http, I was thinking this server can be possibly used by more people to send their data and server displays a chart.
I was ...
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 ...
1
vote
0
answers
65
views
Having a bunch of global variables or calculate them on the go on an Arduino, as far as memory is concerned
So I'm new in the arduino world but I have a grasp of object oriented programming, and decided to write a little library for running games on an arduino mega using a display. My question is, I'm ...
1
vote
1
answer
696
views
Global variable changes its value when loop starts again
I have a problem with the global variable calibrationValue. It is initially set with the correct value and is also displayed correctly in the output. As soon as the loop function is restarted, the ...
0
votes
1
answer
459
views
What does display.setSegments(&segto, 1, 1); do?
I am using a TM1637 display for my Arduino Uno. The goal was to just light up one point of the colon in the middle - what seems to be kind of impossible to accomplish. During research I stumbled over ...
1
vote
1
answer
742
views
Function to control servos
I'm trying to control 6 servos while writing a lean code. I think the function call isn't correctly yet and I think that the variables (pos_n, open_n, servo_1) in the for loop do not get inserted, but ...
2
votes
2
answers
881
views
Using the same variable between if-statements within loop()
I wonder if there is a good way to use the same variable value between two different if-statements within the loop().
Within the Servomotor section of the code, I want to use the value from the first ...
1
vote
1
answer
229
views
Variable sets to 32767 - MATLAB Arduino
I am running out of ideas of what may be causing this problem, and I would appreciate some help identifying anything I am overlooking.
Quick Problem Summary
A variable gets set to 32767 quite often ...
1
vote
4
answers
1k
views
How do arrays work?
It's been days now I'm trying to figure out how arrays work in Arduino IDE.
For better understanding, I assembled some pieces of code I found here and there to write this sketch:
#define arrayLength(x)...
1
vote
2
answers
7k
views
How to display float variables on oled display (0.96'')
I have a similar problem than the discussed here : How to display variables on 0.96" OLED with u8glib library?
I'd like to know how can I show float variables in place of int variables. What ...