ADXL345 Interrupt Setup

Hi there,

I am trying to make a small little project in which I am trying to build da LED Dice (Game Dice with LED Display like this instructable)
But instead of using a button to trigger the random output of the number I want to use an interruptsignal from the ADXL345.

Here is the working code for an Arduino Nano:

#include <SparkFun_ADXL345.h>  
int pinLeds1 = 3;
int pinLeds2 = 2;
int pinLeds3 = 5;
int pinLeds4 = 4;

long ran;
int time = 2000;

ADXL345 adxl = ADXL345(); //SDA A4,SCL A5
void setup ()
{
  Serial.begin(9600);                 // Start the serial terminal
  Serial.println("SparkFun ADXL345 Accelerometer Hook Up Guide Example");
  Serial.println();
  
  pinMode (pinLeds1, OUTPUT);
  pinMode (pinLeds2, OUTPUT);
  pinMode (pinLeds3, OUTPUT);
  pinMode (pinLeds4, OUTPUT);
  //randomSeed(analogRead(0));
  adxlSetup();
}
void adxlSetup()
{
  adxl.powerOn();                     // Power on the ADXL345
  adxl.setRangeSetting(4);           // Give the range settings

  adxl.setSpiBit(0);                  // Configure the device to be in 4 wire SPI mode when set to '0' or 3 wire SPI mode when set to 1

  adxl.setActivityXYZ(1, 1, 1);       // Set to activate movement detection in the axes "adxl.setActivityXYZ(X, Y, Z);" (1 == ON, 0 == OFF)
  adxl.setActivityThreshold(65);      // 62.5mg per increment   // Set activity   // Inactivity thresholds (0-255)

  adxl.ActivityINT(1);

  
//attachInterrupt(digitalPinToInterrupt(interruptPin), ADXL_ISR, RISING);   // Attach Interrupt

}
void loop()
{
  
  if(adxl.triggered(adxl.getInterruptSource(), ADXL345_ACTIVITY)){
    //adxl.ActivityINT(0);
    Serial.println("*** ACTIVITY ***"); 
    delay(300);
    rollDice();
    delay(50);
    while(adxl.triggered(adxl.getInterruptSource(), ADXL345_ACTIVITY))
    {
    }

  }
}

void rollDice()
{
    ran = random(1, 7);
    if (ran == 1){
      digitalWrite (pinLeds1, HIGH);
      delay (time);
    }
    if (ran == 2){
      digitalWrite (pinLeds4, HIGH);
      delay (time);
    }
    if (ran == 3){
      digitalWrite (pinLeds4, HIGH);
      digitalWrite (pinLeds1, HIGH);
      delay (time);
    }
    if (ran == 4){
      digitalWrite (pinLeds2, HIGH);
      digitalWrite (pinLeds4, HIGH);
      delay (time);
    }
    if (ran == 5){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds2, HIGH);
      digitalWrite (pinLeds4, HIGH);
      delay (time);
   }
   if (ran == 6){
      digitalWrite (pinLeds2, HIGH);
      digitalWrite (pinLeds4, HIGH);
      digitalWrite (pinLeds3, HIGH);
      delay (time);
   }
  
  digitalWrite (pinLeds1, LOW);
  digitalWrite (pinLeds2, LOW);
  digitalWrite (pinLeds3, LOW);
  digitalWrite (pinLeds4, LOW);
}

Only now I want to do the same thing with an ATTiny85 which only has 5 I/O s (I know you can use RST aswell but I wanna know if there is another option).
Since the ADXL345 can deliver a simple Interrupt through INT0/INT1 my question is, can i preconfigure the ADXL345 (interrupt enable mask,…) with non volatile values so that in the end I do not need an SPI/I2C connection to the attiny and thus only need 1 I/O pin from the ATTiny for INT0 to trigger “rolling the dice”?

can i preconfigure the ADXL345 (interrupt enable mask,...) with non volatile values so that in the end I do not need an SPI/I2C connection to the attiny and thus only need 1 I/O pin from the ATTiny for INT0 to trigger "rolling the dice"?

No, according to the datasheet this is not possible. But you only need LED outputs, so a double use of the I2C pins should be possible as you most probably will never produce an LED output that matches the I2C start condition and the ADXL address. You might have to change the circuit slightly to enable pull-ups on the I2C signal lines so the LEDs should be LOW active.

Thanks for the reply

I actually never tried to double use an I/O Pin I never thought thats a leggit option.
So one I/O Pin would be connected to SDA/SCL and to one of the LEDs at the same time?
And with low active you mean adding an PNP Transistor between the IO and the LED anode?

There still is the option to use the RESET pin as an additional IO Pin which seems to be more clean but I am having problems with setting the fuses of the attiny with a HV-Programmer and Arduino UNO....

And with low active you mean adding an PNP Transistor between the IO and the LED anode?

No, I meant using the pin as a sink for the LED. So the LED doesn't light up if the I2C bus is in idle state. But the transistor should work too.

There still is the option to use the RESET pin as an additional IO Pin which seems to be more clean but I am having problems with setting the fuses of the attiny with a HV-Programmer and Arduino UNO....

I never used a HV-programmer, so I'm of little help there.