I'm playing around with a Neopixel strip and want to be able to enter the amount of minutes I want an LED to do something rather than in milli seconds. So for example,
void loop() {
colorWipe(strip.Color(0, 0, 255), 50);
delay(sConversion(5));
colorWipe(strip.Color(0, 0, 0), 50);
delay(sConversion(5));
In my mind this should then delay the code by 5 minutes instead of doing
void loop() {
colorWipe(strip.Color(0, 0, 255), 50);
delay(300000);
The function I wrote is
sConversion(int minutes) {
int milli = minutes * 60000;
return milli
};
When I write this same function in JS it returns the correct value, 300000. But when I run it in the Arduino IDE the blue light never changes.
I have this function outside my void loop() and void setup(). Is that the correct place to put it? I have no errors returned.
Full code sample
void setup() {
strip.begin();
strip.show();
}
int sConversion(int minutes) {
int milli = minutes * 60000;
return milli;
}
void loop() {
colorWipe(strip.Color(0, 0, 255), 50); // Blue
delay(sConversion(1));
colorWipe(strip.Color(102, 204, 0), 50); // Green
delay(300000);
}
void colorWipe(uint32_t c, uint8_t wait) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
};
};
Is this the reason?
No other reading of sensors, mathematical calculations, or pin manipulation can go on during the delay function, so in effect, it brings most other activity to a halt.