How do you operate the buzzer with the desired motion after machine learning?

#include <kimyoungmoon-project-1_inference.h>
#include <Arduino_LSM9DS1.h>

#define CONVERT_G_TO_MS2 9.80665f

static bool debug_nn = false; // Set this to true to see e.g. features generated from the raw signal

void setup()
// put your setup code here, to run once:
Serial.println("Edge Impulse Inferencing Demo");

if (!IMU.begin()) {
    ei_printf("Failed to initialize IMU!\r\n");
else {
    ei_printf("IMU initialized\r\n");

    ei_printf("ERR: EI_CLASSIFIER_RAW_SAMPLES_PER_FRAME should be equal to 3 (the 3 sensor axes)\n");


void ei_printf(const char *format, ...) {
static char print_buf[1024] = { 0 };

va_list args;
va_start(args, format);
int r = vsnprintf(print_buf, sizeof(print_buf), format, args);

if (r > 0) {

void loop()
ei_printf("\nStarting inferencing in 2 seconds...\n");



// Allocate a buffer here for the values we'll read from the IMU

for (size_t ix = 0; ix < EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE; ix += 3) {
    // Determine the next tick (and then sleep later)
    uint64_t next_tick = micros() + (EI_CLASSIFIER_INTERVAL_MS * 1000);

    IMU.readAcceleration(buffer[ix], buffer[ix + 1], buffer[ix + 2]);

    buffer[ix + 0] *= CONVERT_G_TO_MS2;
    buffer[ix + 1] *= CONVERT_G_TO_MS2;
    buffer[ix + 2] *= CONVERT_G_TO_MS2;

    delayMicroseconds(next_tick - micros());

// Turn the raw buffer in a signal which we can the classify
signal_t signal;
int err = numpy::signal_from_buffer(buffer, EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE, &signal);
if (err != 0) {
    ei_printf("Failed to create signal from buffer (%d)\n", err);

// Run the classifier
ei_impulse_result_t result = { 0 };

err = run_classifier(&signal, &result, debug_nn);
if (err != EI_IMPULSE_OK) {
    ei_printf("ERR: Failed to run classifier (%d)\n", err);

// print the predictions
ei_printf("Predictions ");
ei_printf("(DSP: %d ms., Classification: %d ms., Anomaly: %d ms.)",
    result.timing.dsp, result.timing.classification, result.timing.anomaly);
ei_printf(": \n");
for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
    ei_printf("    %s: %.5f\n", result.classification[ix].label, result.classification[ix].value);

ei_printf(" anomaly score: %.3f\n", result.anomaly);

#error "Invalid model for current sensor"

I want to operate the buzzer with the above coding, what should I do?

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

I've modified it. Please check.

If you are saying that you modified how you posted your code than you did something wrong again

  • Edit the post with the code in it
  • select all of the code
  • click the </> icon to add the code tags
  • save the revised post

You have a list of labels and values. I expect the 'value' is the probability of a match. I expect the labels are in order of probability (highest first). Is there some label that you want the buzzer to buzz for?!?

There is an automatic function for posting code as one single code-section in the Arduino-IDE:
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

best regards Stefan