Basically i'm trying to wake up the mini pro and check card when rfid card is detected.
I've omitted some non relevant code of course. Pin 2 is connected to IRQ
pinMode(A1, INPUT); // initialize the pushbutton pin as an input:
pinMode(A0, OUTPUT); // green led output
pinMode(A2, OUTPUT); // red led output
pinMode(A3, OUTPUT); // solenoid output
pinMode(A5, OUTPUT); // buzzer output
pinMode(A4, OUTPUT); // yellow led output
#include <SPI.h>
#include <MFRC522.h>
#include <EEPROM.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/io.h>
#include <EnableInterrupt.h>
void PowerDownTimer(){
if (timer_start == false) {
tcurrentMillis = millis();
timer_start = true;
}
tnextMillis = millis();
tnextMillis = tnextMillis - tcurrentMillis;
if (tnextMillis >= tinterval) {
// Soft power-down
mfrc522.PCD_WriteRegister(0x02, 0x10);
delay(2000);
SPI.end();
SPI.begin();
pinMode( 2, INPUT_PULLUP);
enableInterrupt( 2 | PINCHANGEINTERRUPT, interruptFunction, CHANGE);
set_sleep_mode(SLEEP_MODE_PWR_SAVE);
sleep_enable();
sleep_mode();
sleep_disable();
}
}
void interruptFunction(){
disableInterrupt( 2 | PINCHANGEINTERRUPT);
digitalWrite(yellowledpin, HIGH);
}]