Arduino Uno Rev3 function prototype, declaration, and call not working?, and

so am using an Arduino Uno Rev3, and based on my experience with C++, the coding is basically the same. I have yet to meet differences, however it has been a while since I've used C++. If you have experience with either, state which and what I'm doing wrong! any help would be great! Thanks:
NOTE: the Time.h and TimeAlarms.h libraries are Arduino native libraries (I believe) and info on them can be found on arduino sites and forums.

SO, I am trying to work with the function movementDelay() and it isn't working.

prototype:
void movementDelay(boolean);

call:
Alarm.timerOnce(60,movementDelay(thirtyMinDelay))

definition:
void movementDelay(boolean thirtyMinDelay)
{
digitalWrite(7,LOW);//turn off the lights of no movement within
//30 minutes.
thirtyMinDelay = false;
}

the error I am getting is:
PIR.ino: In function 'void loop()':
PIR:26: error: invalid use of void expression
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <Time.h>
#include <TimeAlarms.h>

void setup()
{
pinMode(12,INPUT);
pinMode(7,OUTPUT);//for output to lights.
Serial.begin(9600);
void movementDelay(boolean);
}

void loop()
{
boolean thirtyMinDelay= false;

//senses whether or not the PIR sensor senses movement. It returns either a 5v signal or nothing, respectively.
boolean senseMovement = digitalRead(12);
//Serial.print("sense Movement");
//Serial.println(senseMovement);

//read in light signal from photoresistor. value from 0 to 1023 (0 brightest light level and 1023 is almost utter darkness.
if (senseMovement == true /*&& thirtyMinDelay == false*/)
{
digitalWrite(7,HIGH);//turn the lights on.
thirtyMinDelay = true;
Alarm.timerOnce(60,movementDelay(thirtyMinDelay));//delays shutting off the lights for one minute upon sensing movement.
}

int lightLevel = analogRead(0);
//Serial.print("light level:");
//Serial.println(lightLevel);
}

void movementDelay(boolean thirtyMinDelay)
{
digitalWrite(7,LOW);//turn off the lights if no movement within
//1 minute.
thirtyMinDelay = false;
}
Last edited on
1) Please use code tags when posting code, to make it more readable:

http://www.cplusplus.com/articles/z13hAqkS/

2) You've defined movementDelay() to have no return value (i.e. it's void). But here, you're attempting to use it as if it does have a return value:

Alarm.timerOnce(60,movementDelay(thirtyMinDelay));

Last edited on
Topic archived. No new replies allowed.