Troubleshooting analog input

//

const int analogPin = A5;
const int ledPin = 13;
const int threshold = 100;

void setup() {
pinMode(ledPin, OUTPUT);
}

void loop() {

int analogValue = analogRead(analogPin);

if (analogValue > threshold) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}

Serial.println(analogValue);
delay(100);
}

//

I have 2 arduinos place seperately with identical code to recieve seperate analog inputs. One isn’t appearing as a port on my computer so I cannot upload the code.
The second has the code uploaded but when I open serial monitor to adjust the threshold values it is blank.
Can anyone give any advice?

Don't you need a Serial.begin() in setup() to open a serial port?

One isn't appearing as a port on my computer so I cannot upload the code.

Some boards require drivers to be installed for the USB to serial converter.

I don’t understand how its working fine on one of the arduinos but the other can’t be found

I think this applies

First start with sorting out the "I don't see the Arduino part". I bed they are not 100% the same and use different USB chips (aka, need different drivers) or you just broke one (or both) of the boards.

Issy768:
I don’t understand how its working fine on one of the arduinos but the other can’t be found

oh, the pronoun game !
when it is running does the thing work for the other things it does ?
does it work for the first part properly ?
did you check that bit of code to make sure it worked ?
does that other bit of code work too ?

What is the serial speed set for in setup ?
What is the serial monitor speed set for ?
take the one Arduino you think is running and unplug the other.
Get one to run any of the examples that show up on the serial monitor.
even
loop() {
Serial.println("Hello World");
delay(200);
}
remove the first, then connect the second.
repeat for the second unit.
does the ( Linux/ windoze / Apple) systems say that your (UNO / NANO / Mini / Esp8266 / ESP32 / Mega ) connect ?

Issy768:
I have 2 arduinos place seperately with identical code to recieve seperate analog inputs. One isn’t appearing as a port on my computer so I cannot upload the code.

How can that problem have given rise to the Title chosen for this Thread?

The problem does not seem to have anything to do with the analogRead() function.

...R

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.... :slight_smile: