Hey,
I'm currently working on my first program, which is a flight computer for a rocket. I need to come up with a statement that essentially says "if the current altitude is <= to 300 && that value is decreasing"
So far I have this
while(armed == 4)
{
currentalt = bmp.readAltitude(); //Get the current altitude
adjustedalt = currentalt - groundalt; //Calculate adjusted altitude (altitude above ground level)
read_mpu_6050_data(); //Read the raw acc and gyro data from the MPU-6050
gyro_calcs(); //Calculate filtered values for pitch, roll
recordData(); //Data dump
if((adjustedalt <= 300.0 && armed ==4) || (armed > 2 && adjustedalt <= 300 && **********))
{
digitalWrite(mainChute, HIGH);
armed = 5;
Serial.println("Main Chute Deployed @ ");
I also have a similar problem with landing. As of right now it detects a landing when the altitude is within 1 meter of the takeoff altitude, which is unreliable because of elevation changes, therefore I added an or statement, which basically ends the program if the flight time exceeds 10 minutes. However, I would like to say something like "if (altitude <= touchdownalt || current altitude is neither increasing nor decreasing"
This is what I have for that portion:
if((armed == 5 && adjustedalt <= touchdownalt) || (armed == 5 && ((millis() - launchmillis) / 1000) > 600))
I'll include an attachment of the whole sketch, any help would be greatly appreciated, thank you!