GY-63_MS5611/libraries/MAX44007/examples/max44007_interrupt/max44007_interrupt.ino
2022-01-05 16:46:06 +01:00

66 lines
1.1 KiB
C++

//
// FILE: Max44007_interrupt.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo of Max44007 library
// DATE: 2022-01-04
#include "Wire.h"
#include "Max44007.h"
Max44007 myLux(0x5A);
uint32_t lastDisplay = 0;
void setup()
{
Serial.begin(115200);
Serial.print("\nStart Max44007_interrupt : ");
Serial.println(MAX44007_LIB_VERSION);
Wire.begin();
myLux.setContinuousMode();
myLux.setHighThreshold(30);
Serial.print("HighThreshold:\t");
Serial.println(myLux.getHighThreshold());
myLux.setLowThreshold(10);
Serial.print("LowThreshold:\t");
Serial.println(myLux.getLowThreshold());
myLux.setThresholdTimer(2);
myLux.enableInterrupt();
}
void loop()
{
uint32_t interval = 1000;
if (millis() - lastDisplay >= interval)
{
lastDisplay += interval;
float lux = myLux.getLux();
int err = myLux.getError();
int st = myLux.getInterruptStatus();
if (err != 0)
{
Serial.print("Error:\t");
Serial.println(err);
}
else
{
Serial.print("lux:\t");
Serial.print(lux);
if (st == 1) Serial.println("\tIRQ occurred");
else Serial.println();
}
}
}
// -- END OF FILE --