Skip to main content

Questions tagged [variables]

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

Filter by
Sorted by
Tagged with
-2 votes
1 answer
81 views

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 ...
Warby's user avatar
  • 1
-1 votes
1 answer
363 views

So I have: 1/ My myapp.ino file, that includes src.h (implemented in src.cpp). Compiled for Arduino Uno. 2/ I also have a unit-tests.cpp file that is meant to test functions in src.cpp. Compiled for ...
theredled's user avatar
-1 votes
1 answer
958 views

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 ...
Sireesha's user avatar
1 vote
2 answers
114 views

Working on a project where I get an input where its a comma delimited string like: "255,10000000,42949672950254,12,22". and then the numbers (no commas), would be split into 6 Long ...
The Oracle's user avatar
0 votes
1 answer
1k views

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,...
TeD van Loon's user avatar
0 votes
2 answers
314 views

i get the current time with the example code istimneforset, everything works fine. now i want to get the current time from the function "Serial.println(timeClient.getFormattedTime());" and i ...
Mike's user avatar
  • 11
1 vote
1 answer
280 views

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 ...
user1584421's user avatar
  • 1,435
0 votes
1 answer
261 views

I have a SHT30 sensor for Wemos and I am learning to use Arduino IOT Cloud. I use float data type for my temperature variable but I see two more data types: CloudTemperature CloudTemperatureSensor ...
Roby Sottini's user avatar
0 votes
1 answer
95 views

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 ...
Mark's user avatar
  • 393
-2 votes
1 answer
851 views

i am transmitting sensor data from my atmega328p to my esp8266. The Sensordata has 3 decimal places. The esp8266 sends this data to my pc and there I see only two digits. This is because the data is ...
kaan's user avatar
  • 1
0 votes
1 answer
86 views

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-...
user avatar
0 votes
3 answers
2k views

I am new to arduino and I want to make a project where I have a motor spinning clockwise then when a button is pressed it spins anti-clockwise and if it is pressed again it goes back to clockwise etc.....
bstplyr2401's user avatar
1 vote
1 answer
449 views

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 ...
Vitor Z.'s user avatar
-1 votes
1 answer
113 views

I'm a little dumbfounded as to why this isn't working. I keep getting the following linker error: In file included from src\ac.cpp:1:0: src/ac.h:9:21: error: expected identifier before numeric ...
Jeebus's user avatar
  • 3
2 votes
1 answer
3k views

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 ...
Harry J Crowley's user avatar
1 vote
2 answers
3k views

I want to know if bool variable can be null, or it must have to be true or false: Base on Arduino description: A bool holds one of two values, true or false. (Each bool variable occupies one byte of ...
Shahreza's user avatar
  • 165
2 votes
1 answer
362 views

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 (...
Jeff Parisse's user avatar
2 votes
2 answers
1k views

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; // ...
Zhelyazko Grudov's user avatar
-1 votes
1 answer
156 views

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 ...
Subha Jeet Sikdar's user avatar
1 vote
1 answer
2k views

I have an Arduino program written for the nRF52 with which runs for a pre-set time-value (i.e. 2 minutes) before shuts off automatically. The variable time-value can be changed via BLE-write by the ...
TommyS's user avatar
  • 71
1 vote
0 answers
118 views

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 ...
Nicky's user avatar
  • 11
0 votes
1 answer
908 views

I have a Nodemcu with which i'm doing a project. So whenever there is a power loss i want values of some of the variables to not be reset, because of that im trying to store the values in EEPROM of ...
rohithrathod banoth's user avatar
1 vote
2 answers
993 views

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 ...
Coder9390's user avatar
  • 512
0 votes
1 answer
107 views

I am trying to make a circuit that will be used for turning on a light whenever there are 1 or more people in a room. I need to add to a variable counter when someone enters and subtract when someone ...
NinePlusTenEqualsTwentyOne's user avatar
0 votes
2 answers
412 views

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
Brandon's user avatar
0 votes
1 answer
54 views

I modify this code from my friend and it look strange. void setup() { Serial.begin(115200); Serial.println("reset"); } void loop() { for (int d; d <= 32767; d++) { ...
M lab's user avatar
  • 131
1 vote
1 answer
955 views

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 ...
dogfood's user avatar
  • 51
1 vote
1 answer
1k views

I have this code that takes temperature and humidity values from a DHT11 sensor and number of faces from an external python code and prints them on an OLED screen but instead of values of variables it ...
vueenx's user avatar
  • 19
1 vote
0 answers
1k views

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 ...
Jonathan Talbot's user avatar
1 vote
1 answer
528 views

I want to change or declare a constant in the setup() and then, I want to access it in the loop(). I have searched a lot, but the only questions I found could be solved by declaring the constant in ...
Vooxe's user avatar
  • 21
1 vote
3 answers
174 views

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 ...
adrianTNT's user avatar
  • 252
1 vote
1 answer
172 views

#include <Adafruit_NeoPixel.h> const int PIN = 4; const int NUMPIXELS = 10; const int BUTTONPIN = 6; int buttonState = 0; int PINState = 0; int level = 1; int dt = 100; Adafruit_NeoPixel pixels(...
louise moons's user avatar
7 votes
2 answers
3k views

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 ...
metichi's user avatar
  • 181
1 vote
1 answer
341 views

Sorry i am a beginner and amateur when it comes to coding, can somebody help me to make the code inside the loop() less "monkey-like" by using a proper function? I have tried a lot and at ...
Baka's user avatar
  • 11
1 vote
0 answers
65 views

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 ...
Juan's user avatar
  • 11
0 votes
2 answers
513 views

I have two characters, that I get by Bluetooth. char a = SerialBT.read(); char b = SerialBT.read(); According to the Arduino Reference, decoded data stored in a char gets encoded to ASCII text. I ...
Python Schlange's user avatar
1 vote
1 answer
697 views

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 ...
Gary77's user avatar
  • 13
0 votes
1 answer
475 views

This is my first time working on Arduino for my project and I ran into an issue. I'm trying to make a very simple Vending Machine. Coin or any obstacle passes in front of the IR sensor and based on ...
Moeed Rehman Masood's user avatar
0 votes
1 answer
460 views

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 ...
data-research's user avatar
3 votes
1 answer
13k views

Hello Arduino Stack Exchange, I have an an enum instance called state: enum States { SLEEP, AWAKE, CRAZY } state; States state = SLEEP; I would like to convert the value of state to a String so ...
Intrastellar Explorer's user avatar
1 vote
1 answer
745 views

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 ...
Vincent's user avatar
  • 13
0 votes
1 answer
499 views

I'm trying to merge 2 Arduino samples, in order to be able to use DS3231 RTC module with ESP8266 WiFi simple web server. My RTC library is this: https://github.com/Makuna/Rtc/wiki Generally, to code ...
Offer's user avatar
  • 107
2 votes
2 answers
881 views

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 ...
John's user avatar
  • 31
0 votes
1 answer
364 views

If you want to have functions within a library that only the library itself should be able to use or variables that shouldn't be accessed from outside, you usually make them private by writing this in ...
LukasFun's user avatar
  • 295
1 vote
1 answer
230 views

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 ...
dquintero's user avatar
0 votes
1 answer
174 views

I want to take the GPS coordinates like 42.1234 per 22.1234 and merge them as a string, with a separator character: 42.1234 x 22.1234 But using this code: gps_string = (String)gps.location.lat()+' ...
adrianTNT's user avatar
  • 252
1 vote
4 answers
1k views

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)...
MrCabana's user avatar
1 vote
2 answers
55 views

I am installing lights in a model train and there are multiple prototypical lighting procedures that need to be activated. The lights are connected as follows: Headlight Top - Pin 1 Headlight Bottom - ...
William Fuhrmann 's user avatar
1 vote
2 answers
7k views

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 ...
Daniel Oliveira's user avatar
0 votes
1 answer
89 views

Can Arduino handle variable variables? function getLetterCode(char input) { int letter_a = 17; int letter_b = 42; int letter_c = 50; return letter_$$input$$; //pseudocode } This is ...
Zsolt Szilagy's user avatar