Passing variables to a function

Hi,

I am building a sensor to alert me when it is time to pump a holding tank that I have on my property. However I am having difficulty with passing variables to my email function. I do have a working email function but I need to customize the subject and change some variables based on what I pass to the function. Right now this is a mock up of the email function and when I get this working I will insert the working code for sending my emails. Right now I am getting these errors when compiling the sketch and I am not quite sure as to how to resolve them.

It seems that when I am trying to either sent or reset the alarms in my code that seems to be the time that the compiler stops. This is one of the alarms. TimeClock=Alarm.timerOnce(120, SendEmail(3));
Thanks for any help you can give.

HoldingTank3.ino.ino: In function 'void setup()':
HoldingTank3.ino.ino:34: error: invalid use of void expression
HoldingTank3.ino.ino: In function 'void loop()':
HoldingTank3.ino.ino:63: error: invalid use of void expression
HoldingTank3.ino.ino: In function 'void SendEmail(int)':
HoldingTank3.ino.ino:105: error: invalid use of void expression
/*
  Holding Tank Alarm v0.01
 
 Reads an analog input on pin 0, converts it to voltage. If voltage is above 0 volts it sends a text that the 
 tank needs to be pumped. Connects wirelessly to WiFi in the house. If connection is lost program will continue
 try to reconnect to WiFi and sends a text that it has reestablished connection. Program checks RTC on startup
 and once a month afterwards to set the time.
 
 */

// add libraries
#include <Time.h>
#include <TimeAlarms.h>


int TimeToEmail;
int VoltageAlarm;
float voltage;
int TimeClock;
int TimeToClock;


void setup() 
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  setTime(22,00,0,1,30,15); 
  SendEmail(2);
 
  TimeToEmail=0;
  // for testing
  float voltage = 1.00;
    // for testing
  Serial.println(voltage);
  TimeClock=Alarm.timerOnce(120, SendEmail(3));
  TimeToClock=1;
  SendEmail(3);
}

void loop() {
  
if(TimeClock=0){
  SendEmail(3);
}
  // off for testing
  // read the input on analog pin 0:
  //int sensorValue = analogRead(A0); 

 // off for testing
 // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
 // float voltage = sensorValue * (5.0 / 1023.0);


  // print out the value you read:
  Serial.println(voltage);

  //display time
  digitalClockDisplay();
  // wait one second between clock display
  Alarm.delay(1000); 

  if (voltage>0 && TimeToEmail==0){
    // timer for every 60 seconds set to 12 hours after testing   
    VoltageAlarm=Alarm.timerOnce(60, SendEmail(1));
    TimeToEmail=1;
  }   
}

void digitalClockDisplay()
{
  // digital clock display of the time
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.println(); 
}

void printDigits(int digits)
{
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}


void SendEmail(int task)
{
  
 if (task=1){
   Serial.println("Sensor Triggered"); 
  TimeToEmail=0;
  voltage=0;
 }
 
 if(task=2){
    Serial.println("Sensor started"); 
  TimeToEmail=0;
  // for testing
  voltage=1;
 }
 
 if(task=3){
     Serial.println("Time set by universal time clock"); 
  Alarm.disable(TimeClock);
  TimeClock=Alarm.timerOnce(120, SendEmail(3));
  TimeToClock=0;
 }
}
if(TimeClock=0)

A problem the compiler won't highlight.

TimeClock=Alarm.timerOnce(120, SendEmail(3));

Those timer functions take function pointers. That's the function name without the () on the end. You can't supply alternate arguments at that point. You'll need to refactor how you do this, either by using a bunch of global variables to keep up with what needs to be there, or by ditching the Alarm class an learning how to write your own timing code.

TimeClock=Alarm.timerOnce(120, SendEmail(3));

What you've done here is call a function. SendEmail(3) calls a function and that function returns void. SO this expression is really:

TimeClock=Alarm.timerOnce(120, void);

and that is where you are getting the invalid use of void from.

Thanks to all. I will have to rethink how I can do this.

d