Good day I am new to arduino i got 1 pressure sensor to work but I want to find out how could I get 1 more pressure sensor to work but both have to work independently any help would be greatly appreciated
Pressure of what?
Which sensor?
Which board?
How frequently?
Please post a link to the pressure sensor data sheet.
I am using a 150 psi pressure transducer 5 volt I already did some coding to get the psi in the serial monitor but I would like to know how to add another sensor Arduino Uno I am using
If you show what you did it will be possible to tell you how to do more.
const int pressureInput =A1;
const int pressureZero =100;
const int pressureMax = 921.6;
const int pressuretransducermaxPSI =150;
const int baudRate =9600;
const int sensorreadDelay =250;
int redPin=3;
int frontBag =4;
int state=0;
int flag=0;
float pressureValue = 0;
void setup() {
Serial.begin(baudRate);
pinMode(pressureInput, INPUT);
pinMode(redPin,OUTPUT);
pinMode (frontBag,OUTPUT);
pinMode(frontBag,LOW);
}
void loop()
{ pressureValue = analogRead(pressureInput);
pressureValue = ((pressureValue-pressureZero)*pressuretransducermaxPSI)/(pressureMax-pressureZero); //conversion equation to convert analog reading to psi
Serial.print(pressureValue, 1); //prints value from previous line to serial
Serial.println("psi");
}
This is how far i reach
It looks like you just need to connect the second pressure sensor to one of the other analog input pins (A0-A5).
const int pressureInput1 = A1;
const int pressureInput2 = A2;
const int pressureZero = 100;
const int pressureMax = 921.6;
const int pressuretransducermaxPSI = 150;
const int baudRate = 9600;
const int sensorreadDelay = 250;
int redPin = 3;
int frontBag = 4;
int state = 0;
int flag = 0;
float pressureValue1 = 0;
float pressureValue2 = 0;
void setup()
{
Serial.begin(baudRate);
// pinMode(pressureInput, INPUT); // NOT used for analogRead()
pinMode(redPin, OUTPUT);
pinMode (frontBag, OUTPUT);
pinMode(frontBag, LOW);
}
void loop()
{
pressureValue1 = analogRead(pressureInput1);
pressureValue1 = ((pressureValue1 - pressureZero) * pressuretransducermaxPSI) / (pressureMax - pressureZero); //conversion equation to convert analog reading to psi
Serial.print(pressureValue1, 1); //prints value from previous line to serial
Serial.print("psi ");
pressureValue2 = analogRead(pressureInput2);
pressureValue2 = ((pressureValue2 - pressureZero) * pressuretransducermaxPSI) / (pressureMax - pressureZero); //conversion equation to convert analog reading to psi
Serial.print(pressureValue2, 1); //prints value from previous line to serial
Serial.println("psi");
}
I attempted to get a 3rd pressure sensor to work just to check and see if I am doing it correct but i think i am still doing something wrong
const int pressureInput1 = A1;
const int pressureInput2 = A2;
const int pressureInput3 = A3;
const int pressureZero = 100;
const int pressureMax = 921.6;
const int pressuretransducermaxPSI = 150;
const int baudRate = 9600;
const int sensorreadDelay = 250;
int redPin = 3;
int frontBag = 4;
int state = 0;
int flag = 0;
float pressureValue1 = 0;
float pressureValue2 = 0;
float pressureValue3 = 0;
void setup()
{
Serial.begin(baudRate);
pinMode(redPin, OUTPUT);
pinMode (frontBag, OUTPUT);
pinMode(frontBag, LOW);
}
void loop()
{
pressureValue1 = analogRead(pressureInput1);
pressureValue1 = ((pressureValue1 - pressureZero) * pressuretransducermaxPSI) / (pressureMax - pressureZero); //conversion equation to convert analog reading to psi
Serial.print(pressureValue1, 1); //prints value from previous line to serial
Serial.print("psi ");
pressureValue2 = analogRead(pressureInput2);
pressureValue2 = ((pressureValue2 - pressureZero) * pressuretransducermaxPSI) / (pressureMax - pressureZero); //conversion equation to convert analog reading to psi
Serial.print(pressureValue2, 1); //prints value from previous line to serial
Serial.println("psi");
pressureValue3 = analogRead(pressureInput3);
pressureValue3 = ((pressureValue3 - pressureZero) * pressuretransducermaxPSI) / (pressureMax - pressureZero); //conversion equation to convert analog reading to psi
Serial.print(pressureValue3, 1); //prints value from previous line to serial
Serial.println("psi");
no decimals with int; if there is a decimal point then it needs to be a float
PE - Everything it's involved with should be a float too
Should I float pressuremax ?????
If the decimal matters then it and everything used with it must be a float (or the decimal is disregarded).
Make a short sketch where
int a = 5.5;
int b = 2;
int c;
c = a * b;
What do you get for c ?
What makes you think that?
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.