2017-07-26 18:24:25 -04:00
|
|
|
//
|
|
|
|
// FILE: max44009_test01.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
2019-09-03 06:22:43 -04:00
|
|
|
// VERSION: 0.1.2
|
2017-07-26 18:24:25 -04:00
|
|
|
// PURPOSE: demo of max44009 library
|
|
|
|
// DATE: 2015-08-06
|
|
|
|
//
|
|
|
|
// Released to the public domain
|
|
|
|
//
|
|
|
|
|
2021-05-28 07:37:15 -04:00
|
|
|
|
2017-07-26 18:24:25 -04:00
|
|
|
#include "Wire.h"
|
|
|
|
#include "Max44009.h"
|
|
|
|
|
2020-02-16 04:00:38 -05:00
|
|
|
Max44009 myLux(0x4A);
|
2017-07-26 18:24:25 -04:00
|
|
|
|
|
|
|
uint32_t lastDisplay = 0;
|
|
|
|
|
2020-02-16 04:00:38 -05:00
|
|
|
|
2017-07-26 18:24:25 -04:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.print("Start max44009_test01 : ");
|
|
|
|
Serial.println(MAX44009_LIB_VERSION);
|
2019-09-03 06:22:43 -04:00
|
|
|
|
|
|
|
Wire.begin();
|
2020-02-16 04:00:38 -05:00
|
|
|
Wire.setClock(100000);
|
2017-07-26 18:24:25 -04:00
|
|
|
}
|
|
|
|
|
2020-02-16 04:00:38 -05:00
|
|
|
|
2017-07-26 18:24:25 -04:00
|
|
|
void loop()
|
|
|
|
{
|
2020-02-16 04:00:38 -05:00
|
|
|
uint32_t interval = 1000;
|
|
|
|
|
|
|
|
if (millis() - lastDisplay >= interval)
|
2017-07-26 18:24:25 -04:00
|
|
|
{
|
2020-02-16 04:00:38 -05:00
|
|
|
lastDisplay += interval;
|
2017-07-26 18:24:25 -04:00
|
|
|
float lux = myLux.getLux();
|
|
|
|
int err = myLux.getError();
|
|
|
|
if (err != 0)
|
|
|
|
{
|
|
|
|
Serial.print("Error:\t");
|
|
|
|
Serial.println(err);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Serial.print("lux:\t");
|
|
|
|
Serial.println(lux);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-28 07:37:15 -04:00
|
|
|
|
2019-09-03 06:22:43 -04:00
|
|
|
// END OF FILE
|