2017-07-26 18:24:25 -04:00
|
|
|
//
|
|
|
|
// FILE: max44009_test01.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: demo of max44009 library
|
|
|
|
// DATE: 2015-08-06
|
2022-11-16 10:00:38 -05:00
|
|
|
//
|
|
|
|
// breakout MAX44009 / GY-49
|
|
|
|
//
|
|
|
|
// +--------+
|
|
|
|
// VCC |o |
|
|
|
|
// GND |o |
|
|
|
|
// SCL |o o| ADDRESS
|
|
|
|
// SDA |o o| -INT
|
|
|
|
// +--------+
|
|
|
|
//
|
|
|
|
// ADDRESS:
|
|
|
|
// 0 = 0x4A
|
|
|
|
// 1 = 0x4B
|
2017-07-26 18:24:25 -04:00
|
|
|
|
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");
|
2022-11-16 10:00:38 -05:00
|
|
|
Serial.println(lux, 3);
|
2017-07-26 18:24:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-28 07:37:15 -04:00
|
|
|
|
2021-12-21 07:31:20 -05:00
|
|
|
// -- END OF FILE --
|