I am using a pre coded example to figure out what I am doing wrong.
I have marked the lines I added to the sketch the sketch works all but the if statement, It is being ignored and I can't figure out why. thanks for any help offeredl
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
for (int i = 0; i <= 3; i++) { delay(500);// I added
int sensorValue = analogRead(A0);
// print out the value you read:
//I added the if statement, the
//serial println is part of the original program
if (sensorValue >530 );Serial.println(sensorValue);
delay(1); } // delay in between reads for stability
}
I see you edit away the question, you are now on track and I hope see that the above will not print values less than or equal 515.
It can be a very hard thing to spot, I myself have stared for a long time at one or another Oops! which has been pointed out without seeing what you all talking about!
Many times the subject will be like
if statement broken
or
for loop not looping
or
when did they change the while statement
&c.
which is simply not the issue 99.9999999 percent of the time. Like never.
When you (anyone) thinks so, check the documentation you prefer and be careful about every comma, semicolon, brace, bracket, period, parenthesis &c. &c.
The compiler will mercilessly do what you tell it; the little details make a difference and so far no one has written a compiler that knows what you meant…
It’s a bitch, TBH. And as I said, we all been there and still get snagged by things like that from time to time.