Answer the question
In order to leave comments, you need to log in
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
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);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question