Expression cannot be used as a function, please help !

Hi I am having a trouble in my code - expression cannot be used as a function and I need help solving it !
If you need any other info tell and I will post it !

#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <Adafruit_NeoPixel.h>


#define PIN  5
#define NUMPIXELS 12



int ButtonA;
long SecondPixels;
long MinPixels;
long HourPixels;


Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);





void setup()
{
  pinMode(ButtonA, INPUT_PULLUP);
  strip.begin();
  strip.show();
  strip.setBrightness(25);
  Wire.begin();

}

void loop()
{


  tmElements_t tm;
  RTC.read(tm);
  short numHoursPixels = tm.Hour();
  short numMinsPixels = ((tm.Minute()) * 12) / 59;
  short numSecondsPixels = ((tm.Second()) * 12) / 60;  // expression cannot be used as a function

  if (SecondPixels == 0)
    SecondPixels = 12;
  if (HourPixels == 0)
    HourPixels = 12;
  if (HourPixels > 12)
    HourPixels -= 12;

  short r, g, b;
  for (short  i = 0; i < 12; i++) {
    r = 0;
    g = 0;
    b = 0;
    if (i == MinPixels - 1)
      r = 255;
    if (i == SecondPixels - 1)
      g = 255;
    if (i == HourPixels - 1)
      b = 255;

    strip.setPixelColor(i, r, g, b);
  }

  strip.show();

}

void Flash_Light(void) {

  int delayval = 500; // delay for half a second


  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  for (int i = 0; i < NUMPIXELS; i++) {

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    strip.setPixelColor(i, strip.Color(255, 255, 255)); // Moderately bright green color.

    strip.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).
  }
}

Post the actual error message. It should have a line number associated with the specific error.

short numHoursPixels = tm.Hour;
  short numMinsPixels = ((tm.Minute) * 12) / 59;
  short numSecondsPixels = ((tm.Second) * 12) / 60;

?

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

When do you expect this to get executed?
I think it belongs in setup().

PowerBot:

  short numHoursPixels = tm.Hour();

short numMinsPixels = ((tm.Minute()) * 12) / 59;
  short numSecondsPixels = ((tm.Second()) * 12) / 60;  // expression cannot be used as a function

Have a look at File > Examples > DS1307RTC > ReadTest. I think you're getting confused with the Time library hour(), minute(), and second() functions, note that capitalization does matter.
Try this instead:

  short numHoursPixels = tm.Hour;
  short numMinsPixels = ((tm.Minute) * 12) / 59;
  short numSecondsPixels = ((tm.Second) * 12) / 60;  // expression cannot be used as a function

I don't have the hardware connected so I didn't actually test it out.

KeithRB:

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

When do you expect this to get executed?
I think it belongs in setup().

No that's fine, see Adafruit_NeoPixel/examples/simple/simple.ino at master · adafruit/Adafruit_NeoPixel · GitHub

Am I being tripped up by a C++ thing? That is certainly not C.

void Flash_Light(void) { looks strange to me.

Shouldn't it be
void Flash_Light() { ?

On the other hand you never call that function; or did you post only a fragment of your sketch?

Whether(tm.Hour)or(tm.Hour())is correct, depends on the declaration of tm

tmElements_t tm;, which depends on the declaration of tm_Elements_t

expression cannot be used as a function

should make pretty clear, which one is correct.

And both versions are possibly valid C / C++ code.


void Flash_Light(void); is valid, but rarely used

Try this one:

void setup() {
}

void loop(void) {
}

Thanks for the help to everyone, the problem is solved.
You may see the code in here.

The problem was that the tm.Hour, tm.Minute and tm.Second are readings from the RTC which I present as functions with the brackets behind them.

Am I being tripped up by a C++ thing? That is certainly not C.

That's OK, though, because the Arduino isn't programmed in C.

@michael_x:
Thanks, another brick in my learning wall :slight_smile: