Hi, everyone,
I'm sure I'm doing something really simple wrong here, but I've read and re-read the reference, and just cant see what it is.
I have a switch, connected to D3, that will select Fahrenheit or Celsius. The temperature is then sent to the display with an 'F' or 'C' after it.
The code to make this choice is:
unit = (digitalRead(3));
Serial.print(unit);
if (unit = 0)
{ units = " F";}
else
{units = " C";}
Serial.print(units);
Serial.print(unit) is showing either 0 or 1, as it should, depending on the position of the switch, but Serial.print(units) always shows 'C', whichever way the switch is.
If I comment out the 'else' part, Serial.print(units) shows 'F', as I'd expect.
What am I doing wrong, please?
Richard