My interpretation of the Electron Reference for pinMODE() and an example suggests a contradiction. Please set me straight or resolve the conflict.
A straight reading of the preceding seems clear enough - don’t. But, observe the particle.variable example pinMode just above void loop():
// EXAMPLE USAGE
int analogvalue = 0;
double tempC = 0;
char *message = "my name is particle";
// variable name max length is 12 characters long
if (Particle.variable("mess", message)==false)
// variable not registered!
// Read the analog value of the sensor (TMP36)
analogvalue = analogRead(A0);
//Convert the reading into degree celcius
tempC = (((analogvalue * 3.3)/4095) - 0.5) * 100;
You seem to be missing to state what does happen and how this contradicts the statement in the docs.
The main point of the docs warning is to not set pinMode()after an analogRead() statement - and you don’t in your code, so no worries.
The point of the first part is in other words: “Don’t set pinMode() before analogRead() since there is no point, it will be overridden anyway”
Agree with you that’s the conflict. The snippet isn’t mine. It comes from the reference on particle variables. It undermines the proposition that you state so succinctly. It makes no sense to do so before. Nubies that are struggling have their confidence undermined by code examples that don’t strictly follow the text. I don’t claim it’s a big or even important error but it doesn’t belong in the example snippet.
That note was a later addition to the text once the “bogus” behaviour was seed, to warn people of the fact till it can be addressed by a bugfix.
While there were some fixes in that direction, it’s not yet solved completely.