Gestire interrupt

FIXME

https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/

http://www.electronicwings.com/nodemcu/nodemcu-gpio-interrupts-with-arduino-ide

differenza fra polling e interrupt

proposta: agganciare rri a sensore PIR

void setup() {
  // put your setup code here, to run once:
  pinMode(D1, INPUT);
  pinMode(D4,OUTPUT);
  digitalWrite(D4, LOW);
  Serial.begin(9600);
 
  attachInterrupt(digitalPinToInterrupt(D1), funzione_di_callback, CHANGE);
}
 
void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("Loop: ");
  Serial.println(digitalRead(D1));
  delay(500);
}
 
 
void funzione_di_callback() {
    int value = digitalRead(D1);
    Serial.print("Nuovo valore: ");
    Serial.println(value);
    if(value == 0) {      
      digitalWrite(D4, LOW);
    } else {
      digitalWrite(D4, HIGH);
    }
}
pub/sistemiembedded/interrupt.txt · Last modified: 2017/11/13 12:44 by atrent
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0