
Arduino Quick Start


#include <M5Unified.h>
#include <Unit_Sonic.h>
SONIC_IO sensor;
void setup()
{
M5.begin();
// sensor.begin(uint8_t trig = 26, uint8_t echo = 36);
sensor.begin(9, 8);
M5.Display.setColorDepth(1);
M5.Display.setFont(&fonts::Orbitron_Light_32);
M5.Display.setTextDatum(middle_center);
}
int point = 0;
int last_point = 0;
void loop()
{
float Distance = sensor.getDistance();
Serial.printf("Distance: %.2fmm\r\n", Distance);
M5.Display.fillScreen(TFT_BLACK);
M5.Display.drawString(String(Distance) + "mm", M5.Display.width() / 2, M5.Display.height() / 2);
delay(100);
}For CoreS3, press and hold the reset button (for about 2 seconds) until the internal green LED lights up, then release it. At this point, the device has entered download mode and is waiting for programming. The red light turns off after the button is released, confirming that the device is in download mode.
