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).
}
}
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.