Hello,
I am using an ADXL345 sensor and a relay and need to do and if/else statement. Is it possible to have the code read the values of the sensor while it is being used then have:
if:() acceleration stays below this value keep relay on else:()acceleration goes above specific value turn relay off
Any advice or suggestions would be much appreciated!
Of course it is. What have you tried ?
I have the library that will let me see what the accelerometer is experiencing but I am not sure what the next step is to incorporate these values into an if statement. I have not tried as I am still new to the code writing. Thank you for your response, and any further help would be greatly appreciated.
Suppose the value read from the sensor is in a variable named accelValue and the threshold value is in a variable named threshold, then the if statement is simplicity itself
if accelrValue < threshold)
{
//code here to turn on the relay
}
else
{
//code here to turn off the relay
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.