Heyo everyone !
I'm in a project where I need to send a signal if I detect vaccuum. I'm sending the signal on PIN 9 but I soon realized that I was only getting 1V.
Tought I was alternating between signal/no_signal but the log provided me with constant and consistent values.
Then I started doubting about my board so I made PIN 10 always output. Under the same load as PIN 9 (I switch the cable connecting from PIN 9 to the circuit, to PIN 10 to the circuit ), I get a good 5V. Thus, I exclude any load problem.
Regarding the PIN output issue, you can all see that it's not missing.
My last hypothesis is that there's some sort of sorcery with my code that I don't know and couln't find on the internet...
Any idea on what might be going on ?
// Constant
const int BL1 = 9;// BINARY LED 1 pin
const int TEST = 10;// BINARY LED 1 pin
const int AP = A0;// ANALOG PRESSOSTAT pin
const int P = 85;// TRIGGER PRESSURE value
// Variables
int LS1 = LOW; // LED 1 STATE
float RPV = 1; // Raw Pressostat Voltage (0-1024)
float PV = 1; // Pressostat Voltage (V)
float PDP = 20; // Pressostat Deduced Pressure (kPa)
// Initialization of pins at startup
void setup() {
pinMode(AP, INPUT); // ANALOG PRESSOSTAT pin set as INPUT
pinMode(BL1, OUTPUT);// BINARY LED 1 pin set as OUTPUT
pinMode(TEST, OUTPUT);// BINARY LED 1 pin set as OUTPUT
pinMode(LED_BUILTIN, OUTPUT);// LED_BUILTIN pin set as OUTPUT
Serial.begin(9600);
}
void loop() {
digitalWrite(TEST, HIGH);
RPV = analogRead(AP);
PV = (RPV/1024)*5;
PDP = (-1)*(PV-1)*(-101/4);
Serial.print("Pression: ");
Serial.print(PDP);
if ( PDP > P ){
int LS1 = HIGH; // LED 1 STATE
digitalWrite(BL1, HIGH);
digitalWrite(LED_BUILTIN, HIGH);
Serial.print(" | LED: 1");
}
else {
int LS1 = LOW; // LED 1 STATE
digitalWrite(BL1, LOW);
digitalWrite(LED_BUILTIN, LOW);
Serial.print(" | LED: 0");
}
digitalWrite(BL1, LS1);
Serial.print(" | Trigger: ");
Serial.println(P);
}