B
B
boOogdan2015-03-14 19:08:49
Arduino
boOogdan, 2015-03-14 19:08:49

Who can help with Arduino programming?

Given: arduino with accelerometer. In loop through delay(100) the x coordinate is obtained.
Purpose of the device: a person makes a movement and rotates the device by ~90 degrees. The X value changes from +-3000 to ~-15000. On average, this movement takes from 0.7 to 1.5 seconds. How can you capture this moment?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Doshevsky, 2015-03-16
@MikhailD

If I understood the problem correctly, something like this:

const int minX = 3000;
const int maxX = 15000;
bool isAction = false;

void loop()
{
    int x = GetX();
    if (x >= maxX && !isAction)
    {
        isAction = true;
        // some code . . .
    }
    else if (x <= minX && isAction)
    {
        isAction = false;
    }

    delay(100);
}

the minimum and maximum value of X must be chosen.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question