unknown amount of parameters to function arduino
#include <stdio.h>
int Add(int num, ...) {
int valu;
int total=0;
//Declare a va_list macro and initialize it with va_start
va_list argList;
va_start(argList, num);
for(; num; num--) {
valu = va_arg(argList, int);
Serial.print("valu: ");
Serial.print(valu, DEC);
total += valu;
Serial.print(" total: ");
Serial.println(total);
}
va_end(argList);
return total;
}
void setup ()
{
Serial.begin(9600);
Serial.println(Add(3,2,3,4)); //first arg is number of subsequent variables
}
void loop() {
delay(1000);
}