Will the custom function readColor() affect the Blynk operation and why ? .
// Setup a function to be called every second
timer.setInterval(1000L, sendSeconds);
// Setup a function to be called every second
timer.setInterval(1000L, reoLoop);
}
void sendSeconds() {
Blynk.virtualWrite(V6,j);
j++;
}
void loop() {
Blynk.run();
timer.run();
}
void reoLoop () {
topServo.write(115);
delay(500);
for(int i = 115; i > 65; i--) {
topServo.write(i);
delay(2);
}
delay(500);
color = readColor();
delay(10);
switch (color) {
case 1:
bottomServo.write(25);
a ++;// Red
break;
case 2:
bottomServo.write(38);
b ++;// yellow
break;
case 3:
bottomServo.write(66);
c++;// Green
break;
case 4:
bottomServo.write(94);
d ++;// Brown
break;
case 5:
bottomServo.write(125);
e ++; // Blue
break;
case 0:
break;
}
delay(300);
for(int i = 65; i > 29; i--) {
topServo.write(i);
delay(2);
}
delay(200);
for(int i = 29; i < 115; i++) {
topServo.write(i);
delay(2);
}
color=0;
}
// Custom Function - readColor()
int readColor() {
// Setting red filtered photodiodes to be read
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int R = frequency;
// Printing the value on the serial monitor
Serial.print("R= ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.print(" ");
delay(50);