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

learn more… | top users | synonyms

0
votes
1answer
21 views

Arduino join multiple strings and numbers and then seperate them

OK, I'm working on a remote controlled robot. Both the robot and the remote use Arduino with a Bluetooth shield. The Bluetooth is working and I need to send something similar to this over Bluetooth: ...
1
vote
2answers
47 views

How do I correctly use enum within a class?

I am trying to set the status of an object from a private enum and I'm not sure how to get the private member to the public version in the constructor, and I'm pretty sure I should not be using byte ...
1
vote
2answers
47 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
1answer
70 views

How to change Multiple variable values through Serial Monitor

I am trying ... with minimal success to change/Check and also run voids through the serial monitor .the code i put i am having probles is that when i am try to send a value larger than 9 the value ...
4
votes
2answers
49 views

Use large variables without using much memory

I've wired up a dot matrix, and I display characters on the screen by using something like the example code below. The Char_B variable is a global variable in a library used by the Arduino, and ...
0
votes
0answers
33 views

Variable Confusion [duplicate]

I'm very confused about how variables work in C++. In this program... boolean debounce(void) { static boolean buttonState=LOW; static boolean lastButtonState; boolean currentState = ...
2
votes
1answer
61 views

Run code via NRF24L01+ command “dynamically”?

I'm trying to make a home automation setup but I'm having a bit of trouble. I want to be able to send commands of varying sizes to my arduino, separated by "|" and after receiving it completely it ...
16
votes
3answers
1k views

Why use an int variable for a pin when const int, enum or #define makes much more sense

Why do people use a variable to specify a pin number when the pin is unlikely to change throughout the execution of the code? Many times I see an int being used for a pin definition, int led = 13; ...
1
vote
1answer
50 views

Why is my variable not getting updated?

I have the following snippet of code: const unsigned long fiveMinutes = 5 * 60 * 1000UL; unsigned long lastCheck = 0 - fiveMinutes; unsigned long now = 0; void loop() { now = millis(); if ( now ...
0
votes
1answer
384 views

Converting float to String

How can I convert a float value into a String object without implementing any library? I'd like to avoid using char array.
1
vote
2answers
181 views

How to count the number of times a changing variable reaches a peak value

I am recording a varying distance with an Ultrasonic sensor and Arduino but my problem is I want to display the number of times this variable reaches peak (at an instance the value will be increasing ...
0
votes
2answers
238 views

How to add data without pre-defining variables?

I am currently working on a RFID card reader. I need the reader to send the ID to a storage space. What I am trying to achieve is a person swipes their card, enters their name on the serial monitor, ...
0
votes
2answers
1k views

Arduino raise the error: `does not name a type` when an Object is used outside of the main two blocks setup and loop

I have this: class Person{ public: int age; }; Person p; p.age; void setup() { ... } void loop() { ... } And I got this error: Compiling 'MyProgram' for 'Arduino Mega w/ ATmega2560 (Mega ...
0
votes
1answer
228 views

Global Variable not able to be accessed in function?

I am trying to compile an Arduino program that takes analog input. However, when I declare multiple global variables, it often will not compile and because it throws an error that the variables aren't ...
2
votes
3answers
184 views

How do I turn on or off an array of LEDs based on the value of a variable?

I've created a function whereby an int ('cleanCount') automatically goes up or down (0-1000) based on the situation. The value changes every few milliseconds. Based on the value, I would like to ...
1
vote
1answer
461 views

How to accept user input (array, variables,…)

I am working on a project using my Arduino mega2560 that triggers a solenoid (maximum of three solenoids), my camera and my flash (maximum of two flashes). The core routine is there, and working. ...
0
votes
1answer
282 views

Arduino UNO + CC3000 Wifi Shield, Reading webpage data

I'm new so I might be making a stupid mistake, but I'm declaring: char dollars; at the begging of file, afterwards I'm reading a data from a web page, printing it to my serial. That part work well. ...
0
votes
2answers
291 views

Program button to switch between two values

There is a function on one of my programs I want to be switch on and off by pressing a button. The button is unbiased otherwise I would set the function to read the button's status of HIGH or LOW. So ...
0
votes
2answers
574 views

Matlab to Arduino communication

I am doing some computations on Matlab and I need to send those values to an Arduino Leonardo through USB serial connection. I need to send 2 variables which can vary from -400 to +400. I'm saying ...
0
votes
1answer
104 views

Can't store temperature in variable ( for further processing)

I am trying to store temperature data in a variable, so that I can use it for making a JSON object, but the problem is, that when I try to store the temperature in a variable, it prints out the wrong ...
4
votes
1answer
796 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
1answer
318 views

How to pass value of a function from the RFID-RC522 library into a variable then be sent into either serial or ethernet?

I'm using an RC522 RFID reader with an Arduino UNO. There is a function?? (or whatever it's called :)) in Miguel Balboa's new MFRC522.h library which is mfrc522.uid.uidByte[i] that prints the bytes of ...
5
votes
2answers
512 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
3answers
4k views

Convert long to char array and back

I'm trying to store a state in my data logger. I can read/write fine to SD, but I can't wrap my head around reading/writing a long value correctly - I've build it down to converting it to char array ...
4
votes
1answer
533 views

Assuring an unsigned long int?

Basic question: How far do I have to go to assure that integer math is done correctly? For example, this is probably overdone: unsigned long burnTime = 0UL; unsigned long curBurnTime = 0UL; // Do ...
0
votes
3answers
310 views

Help with a function that accepts different parameter types

I'm trying to create a function that prints out an XML tag with a value. I have the code below, but kind of stuck. I'd like to be able to call the function, and pass a value that could be a float, ...
5
votes
2answers
23k 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 ...
0
votes
2answers
133 views

Debugger with Breakpoint and Variable read/set capability

Is there any free/open or commercial/paid Arduino IDE Sketch Debugger (not Atmel chip factory standard tool set) with Breakpoint and Variable read/set capability? I read about VM on web. Is there ...
0
votes
1answer
428 views

How to send multi variable information over serial?

I would like to send information between my Arduino and my computer. Is there a way to send multiple variables from one Arduino? If so, how would I go about separating the variables?
5
votes
1answer
3k 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 ...
1
vote
1answer
814 views

Trouble with variable types and integrating DHT11 temperature sensor

I am trying to modify this sketch; https://github.com/itsallvoodoo/home_automation/blob/master/Arduino_HVAC_Controller/HVAC_Controller/HVAC_Controller.ino But I have a different temperature sensor, a ...
0
votes
1answer
115 views

Assigning formatted value to variable

Look at this snippet of code (from TinyGPS++ library): Serial.print(gps.location.lat(), 6); It prints the latitude location with 6 decimal points. I want, instead of printing that value, to have it ...
1
vote
2answers
1k views

Default value of global variables is not set

I am tracking a bug in the Marlin source code. Background Just for those who is not familiar with Reprap 3D printer and G-code: Marlin is firmware that controls a RepRap 3D printer. It receives ...
0
votes
3answers
2k 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
19 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: ...
0
votes
2answers
2k 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?