I have two operations using setInterval().
One is to read out a sensor via I²C and on the other hand I would like to let a LED blink, depents on the counter value, e. g. counter == 3 >>> LED should blink 3 times all 10 seconds.
My problem is that the LED blinks continiously - I tried it with arguments but it does not work.
///Sensor_Data
setInterval(() => {
i2c.writeTo(0x18, 0xAA, 0x00, 0x00);
setTimeout(() => {
let output = i2c.readFrom(0x18, 5);
var output_bit = output[1] *100 *100 + output[2]*100 + output[3];
var pressure1 = (output_bit-1200000)*(1-(-1));
var pressure2 = pressure1/(1500000-1200000);
var pressure_final = pressure2 + (-1) - 0.29;
log(pressure_final, counter);
///Counter
if (pressure_final < -0.2) {
status_counter = 1;
}
if ((status_counter == 1) && (pressure_final > -0.2) && (pressure_final < 0.2)) {
counter = counter + 1;
if (counter + 1) {
status_counter = 0;}
}
if (counter > 6){
counter = 1;
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Is it possible to set different intervals?
I have two operations using setInterval().
One is to read out a sensor via I²C and on the other hand I would like to let a LED blink, depents on the counter value, e. g. counter == 3 >>> LED should blink 3 times all 10 seconds.
My problem is that the LED blinks continiously - I tried it with arguments but it does not work.