how to reference a sensor ?

hello im trying to reference a sensor for my factor regarding outside pressure (gauge zero)

i would like to know, if i set up a flaot bbc=0 and then change it in the loop, it changes iv checked it..why will it keep reading if (abc = 0) bbc=1.000/(analogRead(A0)*0.00488281) ; its very frustrating.

int abc=1;
float bbc=0; 
void setup() {
   Serial.begin(9600); 
 
}
void loop() 

{
  
  if (abc = 1) bbc=1.000/(analogRead(A0)*0.00488281)  ;
  int abc =0 ;
  int bst = analogRead(A0);
 delay(10);
   float bstinput = bst * (5.0 / 1024.0);
   float bstinput2 = bstinput * bbc;                                                                            //int bstinput = ((bst*0.004887)*0.5376); // "1023/5= 0.004887"x"analogread 0-1023"=voltage  voltage*0.5376= boost in absolute bar  
   float bstinput3 = bstinput2-1.000; // (boostabs-outside)x"bar to psi "
   float bstinput1= bstinput3*14.5038;


 int duty=00;
  Serial.println(abc);
  ;
}
int abc=1;
float bbc=0; 
void setup() {
   Serial.begin(9600); 
  bbc=1.000/(analogRead(A0)*0.00488281)  ;
}
void loop() 

{
  


  int bst = analogRead(A0);
 delay(10);
   float bstinput = bst * (5.0 / 1024.0);
   float bstinput2 = bstinput * bbc;                                                                            //int bstinput = ((bst*0.004887)*0.5376); // "1023/5= 0.004887"x"analogread 0-1023"=voltage  voltage*0.5376= boost in absolute bar  
   float bstinput3 = bstinput2-1.000; // (boostabs-outside)x"bar to psi "
   float bstinput1= bstinput3*14.5038;


 int duty=00;
  Serial.println(bstinput1);
  ;
}

that looks to work now. but if i dont use float for 0.## and used int it wont save the data

In your code you are masking abc by declaring a new copy of abc in a inner scope. If you wanted to set the global abc to 0 drop the ‘int’ in front of your assignment in the function loop().

http://en.cppreference.com/w/cpp/language/scope

Also, if you are trying to toggle something on/off then you should use a boolean. “int abc = 1” would make a lot more sense as “bool initialized = false”. Granted, you should just initialize in setup and not worry about doing it in the loop function.

thanks for the info. yea just realized that i was setting up another variable over another one... red face....

i dont think i should set up another factor regarding input voltage at start up. im trying to turn a abs pressure sensor to read gauge pressure. in this case 1.01325/1.742 was my voltage to pressure factor as the sensor is linear

try

if (abc == 1) bbc=1.000/(analogRead(A0)*0.00488281)  ;

http://en.cppreference.com/w/cpp/language/operator_comparison

hi MasterT that worked great thanks

int abc=1;
float bbc=0; 
void setup() {
   Serial.begin(9600); 
 
}
void loop() 

{
  
  if (abc == 1) bbc=1.000/(analogRead(A0)*0.00488281)  ;
   abc =0 ;
  int bst = analogRead(A0);
 delay(10);
   float bstinput = bst * (5.0 / 1024.0);
   float bstinput2 = bstinput * bbc;                                                                            //int bstinput = ((bst*0.004887)*0.5376); // "1023/5= 0.004887"x"analogread 0-1023"=voltage  voltage*0.5376= boost in absolute bar  
   float bstinput3 = bstinput2-1.000; // (boostabs-outside)x"bar to psi "
   float bstinput1= bstinput3*14.5038;


 int duty=00;
  Serial.println(bstinput1);
  ;
}

so heres a working solution for zero reading the gauge

int bst; 
float zero;
void setup() {
   
  Serial.begin(9600); 
   float bst1 = analogRead(A0);
   float bstinput10 = bst1 * (5.0 / 1024.0);
   float bstinput20 = bstinput10 * 0.5740;                                                                            
   float bstinput30 =( bstinput20-1.000);
   zero= (bstinput30*14.5038);
  ;
}  

void loop() 

{

  int bst = analogRead(A0);
 delay(10);
   float bstinput = bst * (5.0 / 1024.0);
   float bstinput2 = bstinput * 0.5740;                                                                            //int bstinput = ((bst*0.004887)*0.5376); // "1023/5= 0.004887"x"analogread 0-1023"=voltage  voltage*0.5376= boost in absolute bar  
   float bstinput3 = bstinput2-1.000; // (boostabs-outside)x"bar to psi "
   float bstinput1= (bstinput3*14.5038)-zero;


  Serial.println(bstinput1);
  ;
}