Index
 
  Reference for Wiring 1.0 (ALPHA) 0017+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.
Name  

attachInterrupt()

   
Examples  
void setup() { 
  attachInterrupt(0, myFunction, LOW); // set myFunction to be called everytime 
                                  // interrupt 0 is generated (everytime the pin gets LOW) 
  Serial.begin(9600);             // Starts serial to print data 
} 
 
void loop() { 
 
} 
 
void myFunction() { 
  Serial.print("hello "); 
} 

Description   It is possible to generate and attend external interrupts on the Wiring I/O board. There are 8 external interrupts, from 0 to 7 so there are 8 pins on the Wiring I/O board capable of external interrupts, 0, 1, 2, 3, 36, 37, 38, and 39 respectively. In addition to being regular digital pins, note that pins 0 and 1 are also used for the Wire library (TWI) and pins 2 and 3 are also the Serial1 serial port pins. The attachInterrupt() method sets the function that executes whenver an external interrupt is generated. It also sets the mode in which external interrupts can be triggered depending on the state of the interreuption pin pin, LOW when a pin is low, CHANGE when the pin changes, RISING when the pin goes from low to high or FALLING when the pin goes from high to low. The Interruption mode can also be set at a later time by using the interruptMode() method.

Wiring I/O 보드에서 인터럽트 처리가 가능하도록 합니다. 0 부터 7 까지의 8 개의 인터럽트 처리가 가능하며 인터럽트핀은 0, 1, 2 , 3, 36, 37, 38 그리고 39 핀을 사용할 수 있습니다. 0 과 1 번 핀은 TWI(I2C)인터페이스 그리고 2, 3 은 Serial1 시리얼 통신의 기능으로 중복됩니다. (이 기능을 사용하면 인터럽트를 사용할수 없습니다)  attachInterrupt() 에 의하여 언제든지 외부 인터럽트가 발생하면 함수를 실행하도록 설정합니다. 외부 인터럽트의 유형을 선택합니다. LOW 는 핀이 0 이될 때 CHANGE 는 핀의 상태가 변화될 때, RISING 은 0 에서 1 로 변할 때, FALLING 은 1 에서 0 으로 변할 때 이터럽트가 발생합니다. 인터럽트 모드는  interruptMode() 에 의하여 나중에 변경할 수 있습니다.

 

   
Syntax  
attachInterrupt(interrupt, function, mode)
   
Parameters  
interrupt   The number of the external interrupt, from 0 to 7
인터럽트 번호
function   The name of the function to be called whenever the interrupt event happens
인터럽트가 발생하였을 때 실행할 함수 이름
mode   LOW, CHANGE, RISING or FALLING: 외부 인터럽트 트리거링 모드

 the mode the external interrupt is triggered

   
Returns   None
   
Usage   Application
   
Related   detachInterrupt()
interruptMode()
LOW
CHANGE
FALLING
RISING