External interruption:
Based NodeMcu digital IO of ESP8266 interrupt function by attachInterrupt, detachInterrupt function supports. In addition to D0 / GPIO16, interrupts can be bound to any GPIO pin. The standard interrupt types are supported: CHANGE (change in the level from low to high or high to low), RISING (rising edge, from low to high level), FALLING (falling edge, high to low )
attachInterrupt (the pIN, function, the MODE); set the trigger interrupt pin
pin: To set the interrupt number, note that this is not the pin number
function: function runs when the interrupt occurs, this function takes no arguments, returns nothing
Interrupt type / mode: it defines the way interrupt condition is triggered
CHANGE: change along the pin level from low to high or high to low when an interrupt is triggered from.
RISING: rising edge triggered interrupt pin level from low to high.
FALLING: falling edge triggers an interrupt pin level from high to low
Return Value: None
detachInterrupt (pin); Cancels a specified interrupt pin
pin: Interrupt number
Return Value: None
digitalPinToInterrupt (pin); Gets the specified number of interrupt pins
pin: To obtain the interrupt number of GPIO pins
Returns: IRQ
Example 1:
The NodeMcu the D2 pin to the rising edge interrupt. An external button on D2, button down to ground through a resistor. When an interrupt occurs, we print "Hello ESP8266" on the serial monitor
Long emperor arrogance