Hey guys!
I finished my code for the Arduino Nano that will analyze to see when the rocket has passed apogee and then deploys a servo that would release the parachute. The issue arises when I attempt to see the Code it's supposed to print. It only prints "REBOOT" and stops there.
Here's the code
// Your sketch must #include this library, and the Wire library.
// (Wire is a standard library included with Arduino.):
#include <SFE_BMP180.h>
#include <Wire.h>
#include <Servo.h>
// You will need to create an SFE_BMP180 object, here called "pressure":
SFE_BMP180 pressure;
Servo servo;
int Check_downs = 0;
double baseline; // baseline pressure
void setup()
{
Serial.begin(9600);
Serial.println("REBOOT");
// Initialize the sensor (it is important to get calibration values stored on the device).
if (pressure.begin()){
Serial.println("BMP180 init success");
}
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.
Serial.println("BMP180 init fail (disconnected?)\n\n");
while(1); // Pause forever.
}
// Get the baseline pressure:
baseline = getPressure();
Serial.print("baseline pressure: ");
Serial.print(baseline);
Serial.println(" mb");
Serial.print("baseline pressure: ");
Serial.print(baseline/33.864,0);
Serial.println(" Inhg");
servo.attach(2);
servo.write(90); //sets servo to its midpoint
}
void loop()
{
double a,P,a1,a2,P2,Difference;
// Get a new pressure reading:
// Show the relative altitude difference between
// the new reading and the baseline reading:
//a = pressure.altitude(P,baseline);
//Serial.print("relative altitude: ");
//if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
//Serial.print(a,1);
//Serial.print(" meters, ");
//if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
P = getPressure();
a1 = pressure.altitude(P,baseline);
delay(3000);
P2 = getPressure();
a2 = pressure.altitude(P2,baseline);
Difference = a2 - a1;
if (abs(Difference) > 1) {
if (Difference < 0 ) Check_downs =+ 1;
if (Difference > 0 ) Check_downs = 0;
}
Serial.print("Start >");
Serial.print(a1);
Serial.print(" meter >");
Serial.println(a2);
Serial.print("Difference: ");
Serial.print(a1 - a2);
Serial.println("meters");
Serial.print("Check downs : ");
Serial.print(Check_downs);
Serial.println();
if (Check_downs == 3) {
servo.write(90);
}
delay(1000);
}
double getPressure()
{
char status;
double T,P,p0,a;
// You must first get a temperature measurement to perform a pressure reading.
// Start a temperature measurement:
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.
status = pressure.startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed temperature measurement:
// Note that the measurement is stored in the variable T.
// Use '&T' to provide the address of T to the function.
// Function returns 1 if successful, 0 if failure.
status = pressure.getTemperature(T);
if (status != 0)
{
// Start a pressure measurement:
// The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.
status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed pressure measurement:
// Note that the measurement is stored in the variable P.
// Use '&P' to provide the address of P.
// Note also that the function requires the previous temperature measurement (T).
// (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.
status = pressure.getPressure(P,T);
if (status != 0)
{
return(P);
}
else Serial.println("error retrieving pressure measurement\n");
}
else Serial.println("error starting pressure measurement\n");
}
else Serial.println("error retrieving temperature measurement\n");
}
else Serial.println("error starting temperature measurement\n");
}
It used to be able to print but idk what changed...
Can anyone help?