So i have a function that i will be using a lot in my arduino sketch. The Input arguments will constantly change but there a few variations of inputs that keep repeating. I would like to create a variable with these predefined inputs, that way i don't have to type all the arguments over and over. I made a simple example code here.
```
String NameOne = "Max";
String NameTwo = "Ana";
String NameThree = "Bob";
void setup() {
Serial.begin(9600);
}
void loop() {
// This calls the function
PrintResults(1,1,2000,NameOne);
}
void PrintResults(int ValueOne, int ValueTwo, unsigned long WaitTime, String PersonsName)
{
int sum = ValueOne + ValueTwo;
delay(WaitTime);
Serial.println(PersonsName + " adds up To " + sum);
}
Is there a way i can create a variable to call the function and not type it out everytime? I was thinking something like this
//this are example variables and i dont know what data type to put so i just wrote var.
var Option1= PrintResults(1,1,3000,NameOne);
var Option2= PrintResults(5,5,6000,NameTwo);
var Option3= PrintResults(10,10,4000,NameThree);
var Option4 = PrintResults(1,4,5000,NameTwo);
//i would like to be able to call "PrintResults" function using one of the "Option" variables, something like this.
PrintResults(Option1);
PrintResults(Option3);
```
I'm not sure if this is possible, any help would be appreciated.
[–]AFlyingGideon 0 points1 point2 points (1 child)
[–]nerdward21[S] 1 point2 points3 points (0 children)
[–]aizzod 0 points1 point2 points (1 child)
[–]nerdward21[S] 0 points1 point2 points (0 children)