Seeeduino xiao running program issue

Some time ago a started using a seeeduino xiao, just for debugging functions and sensors. It works perfectly well. So now I its time to put it to work in a real application. It wil be a controller for solar powered compressor refrigerator with touchpad and screen.
But the most basic thing does not work; it does not start without a trigger from the ide serial monitor. The blink program works fine standalone, but my simple script does not, have a look:

#include "Adafruit_FreeTouch.h"

Adafruit_FreeTouch qt_1 = Adafruit_FreeTouch(A6, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
Adafruit_FreeTouch qt_2 = Adafruit_FreeTouch(A7, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);

void setup() {
  SerialUSB.begin(115200);
  if (! qt_1.begin())
    SerialUSB.println("Failed to begin qt on pin A6");
  if (! qt_2.begin())
    SerialUSB.println("Failed to begin qt on pin A7");
  pinMode(LED_BUILTIN, OUTPUT);
}

int qt1_Threshold = 260;
int qt2_Threshold = 250;

void loop()
{
  int qt1 = 0;
  int qt2 = 0;

  qt1 = qt_1.measure();
  qt2 = qt_2.measure();

  if (qt1 >= qt1_Threshold) {
    SerialUSB.print("qt1: ");
    SerialUSB.println(qt1);
  }
  if (qt2 >= qt2_Threshold) {
    SerialUSB.print("qt2: ");
    SerialUSB.println(qt2);
  }
  delay(500);
}

I hope someone know what going on.
Thank you,
Ray

I'm not familiar with the Xiao but that sounds like native USB. Usually you will put a while(!Serial) in setup() but I suspect that you left that out on purpose because it would never start without a terminal program opening the connection.

However, it might very well be that the Xiao implementation has some more requirements when it comes to printing over USB and block if no serial connection to a terminal program is open.

A simple test could be to take blink, add some serial stuff and see if the led is still blinking.

That a will try later today, thanks!

Mistry solved, I was running in circles in my head, it was working all this time but I was focused on that blue LED_BUILTIN which blinks on TX apparently.

So adding digitalWrite(LED_BUILTIN, HIGH); and LOW did blink an other LED_BUILTIN, this one is yellow.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.