i have tried also an other code but its gives the same results
#include <Wire.h>
#include <BH1790GLC.h>
#include <FlexiTimer2.h>
#include <stdio.h>
BH1790GLC bh1790glc;
volatile bool timer_flg;
char str[100];
void timer_isr(void);
void setup() {
byte rc;
timer_flg = false;
Serial.begin(115200);
while (!Serial);
Wire.begin();
Wire.setClock(400000L);
rc = bh1790glc.init();
if (rc != 0) {
Serial.println("BH1790 initialize failed");
} else {
Serial.println("LEDON Data, LEDOFF Data");
FlexiTimer2::stop();
FlexiTimer2::set(250, 1.0/8000, timer_isr); // 32Hz timer
FlexiTimer2::start();
}
}
void loop() {
byte rc;
unsigned short val[2];
if (timer_flg) {
rc = bh1790glc.get_val(val);
if (rc == 0) {
sprintf(str, "%d, %d\n", val[1], val[0]);
Serial.print(str);
}
timer_flg = false;
}
}
void timer_isr(void) {
timer_flg = true;
}