Announcement

Collapse
No announcement yet.

attachInterrupt()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • attachInterrupt()

    Hi Greig,
    do you think is it possible to use the attachinterrupt() in API sketch?

    I'm using an API sketch to calculate the duration between 2 pulse (1 pulse every 1W).
    In the same sketch I added 2 onewire DS18B20 sensor. I'm having delay on pulse reading duration because DS18B20 needs 750ms to elaborate the temperature.

    My idea is to use attachinterrupt() to calculate the duration between pulse.

    Code:
    /////PULSE CONSUMI////START
    
    unsigned long tempo_trascorso = millis();
    
    void setup(){
           
           attachInterrupt(0,calcola_tempo,FALLING);
    }
    void calcola_tempo(){
       duration=millis()-tempo_trascorso;
       tempo_trascorso=millis();   
    }
    power = 3600.0 / duration * 1000;
    Do you think the interrupt could cause problem in API sketch?

  • #2
    Yes, it is possible!

    Comment

    Working...
    X