im using a servo motor to release a parachute at a certain altitude however using the if function doesnt seem to work, i have it set to release at a certain temperature as this allows me to test it easier however it doesnt seem to want to do it, this is the code i am using
/*
ReadAnalogVoltage
Reads an analog input on pin 0, converts it to voltage, and prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/ReadAnalogVoltage
*/
#include <Servo.h>
Servo servo;
int sensorValue; //integer variable for value from thermistor
float voltage; //float variable for equivalent voltage from thermistor
float temperature; //float vairable for celcius temperature
int pressureValue;
float pressure;
float pressurework;
bool printFlag = true;
void setup() {
Serial.begin(9600);
servo.attach(8);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
float temperature = voltage*(-28.084) + 97.767;
// print out the value you read:
Serial.print(voltage);
Serial.print(" v ");
Serial.print(temperature);
Serial.print(" C ");
delay(700);
pressureValue = analogRead (A1);
pressurework = ((pressureValue / 1024.0) + 0.095) / 0.0009;
pressure = (pressurework)-((pressurework)*0.0036);
Serial.print("CanSat_Cupertino");
Serial.print("Pressure = ");
Serial.print(pressure);
Serial.println (" millibars");
if (temperature >= 28 )
{
servo.write(90);
printFlag = true;
if (printFlag == true)
{
Serial.print ("Prachute Deployed");
printFlag = false;
}
}
delay (500);
}
the servo code is towards the bottom of the code,
any help is appreciated