GY-63_MS5611/libraries/Max44009/examples/max44009_test01/max44009_test01.ino
Moritz Ulmer fbea3f36f5 Allow multiple Wire interfaces
Why:

- Some boards have multiple I2C interfaces
- Control when TwoWire.begin() is called

This change addresses the need by:

- Option to not begin() Wire
- Always be in configured state (no null ptr crash)
- Internally use TwoWire pointer
- Add example of new functionality
- Add possible I2C addresses
- Update I2C address in example to be within 0 - 127 range
2020-01-19 22:53:40 +01:00

50 lines
768 B
C++

//
// FILE: max44009_test01.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.2
// PURPOSE: demo of max44009 library
// DATE: 2015-08-06
//
// Released to the public domain
//
#include "Wire.h"
#include "Max44009.h"
Max44009 myLux(MAX44009_DEFAULT_ADDRESS);
uint32_t lastDisplay = 0;
void setup()
{
Serial.begin(115200);
Serial.print("Start max44009_test01 : ");
Serial.println(MAX44009_LIB_VERSION);
Wire.begin();
}
void loop()
{
if (millis() - lastDisplay >= 1000)
{
lastDisplay += 1000;
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);
}
}
}
// END OF FILE