L3gd20h data ready interrupt

Hello again,
i wrote a simple program to check if i can read the drdy signal through the interrupt pin

#include "SPI.h"

#define INT1_PIN  8
#define DRDY_PIN  30  // labeled DRDY
#define CS_PIN    10  // labeled CS
#define GYRO_MOSI 11  // labeled SA0
#define GYRO_MISO 12  // labeled SDA
#define GYRO_SCK  13  // labeled SCL
  
const uint8_t L3GD20_REGISTER_CTRL_REG1           = 0x20;   
const uint8_t L3GD20_REGISTER_CTRL_REG3           = 0x22; 

void writeReg(uint8_t reg, uint8_t value) {
  digitalWrite(CS_PIN, LOW);
  SPI.transfer(reg);
  value = SPI.transfer(value);
  digitalWrite(CS_PIN, HIGH);
}

void interrupt(){
  
  f++;
  
  if(f == 5000){
    
  value = 5000;
  f = 0;
  
  }
  
}

volatile long f = 0, value = 0;

void setup() {
  Serial.begin(115200);

  Serial.println("Type any chaaracter to start");
  
  while (!Serial.available()) {}
  
  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);
  pinMode(DRDY_PIN, INPUT_PULLUP);
  
  attachInterrupt(DRDY_PIN, interrupt, RISING);
  
  SPI.begin();
  SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE3));
 
  /* Switch to normal mode and enable all three channels at 400 Hz */
  writeReg(L3GD20_REGISTER_CTRL_REG1, 0b10001111);

  /* Enable I2_DRDY */
  writeReg(L3GD20_REGISTER_CTRL_REG3, 0b00001000);
  
  do {
    delay(10);
  } while (Serial.read() >= 0);
  
}

void loop() {
  
  Serial.print("value =");
  Serial.println(value);
  delay(250);
  
}

i tried it but it does not work,it shows me on the serial screen always “value = 0” .
What am I doing wrong?

Hello.

What kind of Arduino are you using? Could you post a picture showing all your connections?

Unless you have a 3.3V Arduino, you should not drive the CS pin high because it is not level shifted. Instead, since it is pulled high by default, you can alternate between setting it as an output driving low and setting it as an input (with pinMode(CS_PIN, OUTPUT) and pinMode(CS_PIN, INPUT)) to control it safely.

Kevin