Why isn't my LED responding to pressure readings in AVR128DA48 project?

hey guys, In my ongoing project on real-time pressure monitoring using the AVR128DA48 microcontroller, I’ve set up an alert system that triggers an LED to blink when the pressure exceeds a certain threshold. However, the LED doesn't seem to respond correctly to the pressure values, I have tested the LED separately to ensure it is functioning, verified that the BMP280 sensor is returning valid pressure readings, and also checked the GPIO pin configuration for the LED, yet still fails to respond correctly to the pressure readings, even when the threshold is crossed.
this is my code below:
#include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>
#include <drivers/sensor.h>

#define LED_PIN 13
#define PRESSURE_THRESHOLD 1000  // in kPa

void main(void)
{
    const struct device *led_dev = device_get_binding("GPIO_0");
    if (led_dev == NULL) {
        printk("Failed to bind to LED GPIO device\n");
        return;
    }
    gpio_pin_configure(led_dev, LED_PIN, GPIO_OUTPUT);

    const struct device *bmp280 = device_get_binding(DT_LABEL(DT_INST(0, bosch_bmp280)));
    struct sensor_value pressure;
    
    while (1) {
        sensor_sample_fetch(bmp280);
        sensor_channel_get(bmp280, SENSOR_CHAN_PRESS, &pressure);

        if (pressure.val1 > PRESSURE_THRESHOLD) {
            gpio_pin_set(led_dev, LED_PIN, 1);  // Turn on LED
        } else {
            gpio_pin_set(led_dev, LED_PIN, 0);  // Turn off LED
        }
        k_sleep(K_SECONDS(1));
    }
}

What might be causing this issue, and how can I ensure the LED correctly responds to pressure values?
Solution
Yea thankz @Marvee Amasi I checked the issue was coming from my comparison of the pressure values...I had to use a single unit for it, both for the integer and fractional values..thanks for pointing out
Was this page helpful?