Noob Here

Hi I am attempting to find some functional code for an EC/PPM sensor I bought from Ec/pH Transmitters. The product model number is A1003v1. The only sketch I could find for this particular sensor was in a comment on youtube and it doesn't seem to be working. I have played with it a little bit trying to get it to function and have gotten a few different error codes but they have all pertained to the same line in the sketch. The current error code is the following:

In function 'void loop()':

sketch_jan31a:18: error: 'sensorValue' was not declared in this scope

sensorValue = analogRead(analogInPin);

^

sketch_jan31a:18: error: 'analogInPin' was not declared in this scope

sensorValue = analogRead(analogInPin);

^

sketch_jan31a:20: error: 'outputValue' was not declared in this scope

outputValue = map(sensorValue, 0, 1023, 0, 5000);

^

sketch_jan31a:22: error: 'analogOutPin' was not declared in this scope

analogWrite(analogOutPin, outputValue);

^

exit status 1
'sensorValue' was not declared in this scope

Here is the code, not sure how to upload it as a file

void setup() {
 



const int analogInPin = A1;  
const int analogOutPin = 9; 

int sensorValue = 0;        
int outputValue = 0;       

 
  Serial.begin(9600); 
}

void loop() {
  
sensorValue = analogRead(analogInPin);            
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 5000);  
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);           

  // print the results to the serial monitor:
  Serial.print("sensor = " );                       
  Serial.print(sensorValue);      
  Serial.print("\t EC = ");      
  Serial.println(analogRead(1)* 5.00 / 1024, 2);   

  // wait 10 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(500);                     
}

Place those lines:

const int analogInPin = A1;  
const int analogOutPin = 9; 

int sensorValue = 0;        
int outputValue = 0;

before setup()

Jacques

To understand the cause of the error, read this:
https://www.arduino.cc/reference/en/language/variables/variable-scope--qualifiers/scope/

Awesome! thanks guys :slight_smile: