I doing a project about detect light intensity from ISL29125 RGB light sensor with esp32.
I want to control that when I measure black colour, it will show text 'black' in serial monitor but when I measure the other colours, it will show light intensity of those colours in serial monitor. But I want the light intensity data shows only 20 values.
#include <Wire.h>
#include "SparkFunISL29125.h"
SFE_ISL29125 RGB_sensor;
void setup()
{
Serial.begin(115200);
if (!RGB_sensor.init())
{
Serial.println("Error");
}
}
void loop()
{
//Read light intensity of blue channel
unsigned int blue = RGB_sensor.readBlue();
int num = 10;
int count = 0;
//Detect black colour
if((unsigned int) blue < 10000){
Serial.println("black");
delay(2000);
}
else {
count++;
//Show the light intensity of other colours
Serial.print(blue,DEC);
Serial.println();
if (count>10){
break
}
delay(2000);
}
}
Then, I write this code but it shows this error ' break statement not within loop or switch' How can I solve this? Please help me
is not required... remove it any the program will compile.. but as others have said... there are lots of other problems with your code that you need to fix to get it to do anything useful.
@chayapitcha_sae , your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project.
#include <Wire.h>
#include "SparkFunISL29125.h"
SFE_ISL29125 RGB_sensor;
void setup()
{
Serial.begin(115200);
if (!RGB_sensor.init())
{
Serial.println("Error");
}
}
void loop()
{
//Read light intensity of blue channel
unsigned int blue = RGB_sensor.readBlue();
int num = 10;
static int count = 0;
//Detect black colour
if (blue < 10000u)
{
Serial.println("black");
delay(2000);
}
else
{
count++;
//Show the light intensity of other colours
Serial.println(blue);
if (count > 10) // After 10 times...
{
while (1) ; // ... Do nothing forever
}
delay(2000);
}
}