Interrupt on Nano v1 Nrf51822


#1

Anyone here did made about Interrupt Button on Nrf51822 ? I want to ask : what is GPIO be use Interrupt on chip or we can use any GPIO on that ? Can give me the Example for that ? Thank so much


#2

Hi kaitou26698,
You can develop your application in Arduino like that but you should change the GPIO as you want

const byte ledPin = 13;
const byte interruptPin = 2;
volatile byte state = LOW;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
}

void loop() {
  digitalWrite(ledPin, state);
}

void blink() {
  state = !st  
}