Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
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,...
TeD van Loon's user avatar
1 vote
1 answer
339 views

How do i improve this Code? (or how to pass a Char String into a Function to behave like a Variable)

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
3 votes
1 answer
13k views

Getting enum name from enum instance [closed]

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
4k views

Variable declared inside void setup() is forgotten in void loop()

If I declare a variable in void setup() and try to do something with it in void loop(), it just says that the variable is undeclared. Here is the code: #include "Servo.h" void setup() { ...
ThisIsAron's user avatar
0 votes
1 answer
972 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 ...
Lachlan Etherton's user avatar
1 vote
1 answer
13k views

Call by reference

I am trying to learn 'call by reference'. I want to call a function fcn1 from the main loop and pass a reference of the local variable var to the function fcn1. Next step is to call a second function ...
piiq's user avatar
  • 11
0 votes
1 answer
969 views

Space needed for local String variable

I tried to run this code on my Arduino Uno clone (which has no function so far and is a shortend version of my programm): String rules [16][5] ={ {"B0 B5", "", "", "cs S0", "", }, [...] }; ...
tr01's user avatar
  • 117
0 votes
2 answers
307 views

Conditional compilation, how to determine whether a variable has been declared?

Whilst using #if/#end constructs, how can I determine whether a specific variable has already been declared?, e.g., #if [the variable "pinname" has been declared] Serial.print(F("Pin name: ")); ...
KC Tucker's user avatar
  • 394
0 votes
2 answers
154 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] ...
William Roy's user avatar
0 votes
1 answer
165 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: ...
Starwarsfan2099's user avatar
1 vote
2 answers
1k 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 ...
Danniel Adu's user avatar
0 votes
1 answer
1k 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 ...
bee's user avatar
  • 121
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 ...
Ariser's user avatar
  • 577
5 votes
3 answers
36k 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 ...
Blitz's user avatar
  • 155
0 votes
3 answers
2k 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, int,...
bassteq's user avatar

15 30 50 per page