You are reading a single comment by @psc1988 and its replies. Click here to read the full conversation.
  • 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.

    ///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;
             }
    
About

Avatar for psc1988 @psc1988 started