I'm trying to obtain the sensors' readings as well as making the LED strips to light up at this particular pattern, if the sensor readings reaches certain values. But since both of these codes are inside the void loop()
, there will be a problem. How can I do this correctly?
void loop()
{
currentSensorReading = analogRead(sensorPin);
Serial.println(currentSensorReading );
if(currentSensorReading is in range of certain values){
rainbowCycle(20);
} else { turn LEDs off }
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}