Hi,
I've been working on a code that will operate (with user controls) the pressurization system on a rocket I've been building. I got two TI pressure sensors (http://goo.gl/V73Ag), and hooked them up to A1 and A2. The positive/negative leads were attached to ground and 9. Then it got weird. Instead of a number coming up on the serial monitor, it instead came up as 0 when the pressure sensors were attached. When I took them out, the monitor started reading a bunch of random numbers (mostly around 240 or so). I tried another code (the one pasted below), and it just brought up a number around 1643, whether or not the sensors were plugged in. I'm using an Arduino One board on an Acer Aspire One 532h Netbook (http://goo.gl/S7Ikc). The code is posted below;
int command = 0;
void setup() {
Serial.begin(9600);
pinMode (12, OUTPUT); //Pressure Control Solenoid Valve
pinMode (11, OUTPUT); //Oxidizer Control Solenoid Valve
pinMode (10, OUTPUT); //Emergency Vent Solenoid Valve
pinMode (9, OUTPUT); //Pressure Sensors
digitalWrite (11, LOW);
digitalWrite (10, HIGH);
digitalWrite (12, LOW);
digitalWrite (9, HIGH);
}
void loop() {
if (Serial.available() > 0) {
int P1 = analogRead (A1); //Pressure Gauge
int P2 = analogRead (A2); //Pressure Gauge
int Temp = analogRead (A3); //Engine Thermistors
int command = Serial.read();
switch (command) {
case 1: //Launch Sequence
digitalWrite (10, LOW);
digitalWrite(12, HIGH);
digitalWrite(11, HIGH);
break;
case 2: //End Sequence
digitalWrite (10, HIGH);
digitalWrite (11, LOW);
digitalWrite (12, LOW);
break;
case 3: //Refuel Sequence
digitalWrite (11, LOW);
digitalWrite (12, LOW);
digitalWrite (10, HIGH);
break;
default: //Prints data
Serial.println ('P1 = '+ P1);
Serial.println ('P2 = '+ P2);
Serial.println ('Temp = '+ Temp);
delay (1000);
break;
if (P1 > 100){ //Emergency Shutdown
digitalWrite (10, HIGH);
digitalWrite (11, LOW);
digitalWrite (12, LOW);
}
if (P2 > 100){ //Emergency Shutdown
digitalWrite (10, HIGH);
digitalWrite (11, LOW);
digitalWrite (12, LOW);
}
if (Temp > 100){ //Emergency Shutdown
digitalWrite (10, HIGH);
digitalWrite (11, LOW);
digitalWrite (12, LOW);
}
}
}
}
Hopefully somebody else can figure out why this is happening; I'm not the best at coding. My board could be haunted by a poltergeist for all I know.
Thanks,
Gage