Hello,
Can someone help me out with part of the code ?
When i comment out //Vextoff; it works , but my goal is that aftere measurement vext is turn off.
What i am doing wrong ?
// Turn ext 3.3V
void VextOn()
{
pinMode(Vext, OUTPUT);
digitalWrite(Vext, LOW);
delay(250);
}
void VextOff()
{
pinMode(Vext, OUTPUT);
digitalWrite(Vext, HIGH);
}
static void prepareTxFrame( uint8_t port )
{
VextOn();
int senseDist;
#ifdef USE_VL53L1X
// Try a couple of readings to clear indeterminate values
int tryCount = 5;
do
{
senseDist = sensor.readRangeSingleMillimeters();
tryCount--;
#ifdef DEBUG
Serial.print("got reading ");
Serial.println(senseDist);
#endif
}
while( (senseDist == 8190) && (tryCount != 0) );
if (senseDist == 8190) {
// If we still get an indeterminate reading, return 0
senseDist = 0;
}
if (sensor.timeoutOccurred()) {
senseDist = 1;
}
#endif
// VextOff(); <-- here with // it ok
if (firstMeasurement)
{
if (senseDist == 0)
{
// Set RGB LED to red for the first measurement
pixelss.setPixelColor(0, pixelss.Color(255, 0, 0));
}
else
{
// Set RGB LED to green for the first measurement
pixelss.setPixelColor(0, pixelss.Color(0, 255, 0));
}
pixelss.show(); // Send the updated pixel colors to the hardware.
delay(500);
// Turn off the RGB LED
pixelss.setPixelColor(0, pixelss.Color(0, 0, 0));
pixelss.show();
firstMeasurement = false; // Mark that the first measurement has been done
}
uint16_t voltage = getBatteryVoltage();
appDataSize = 4;
appData[0] = senseDist >> 8;
appData[1] = senseDist;
appData[2] = voltage >> 8;
appData[3] = voltage;