How To Properly Use DS18B20 On Analog Pin

Ok I have found loads of methods for hooking these things up to the digital pins which I'm currently all out of, I do have some shift registers to eventually play around with and learn how to use but for right now I want to use the Temperature sensor on one of the Analog pins which I understand can be configured to be used as digital pins, which is great since I have more of those currently open to me at this time.

My concern is that I am probably not coding the pin setup correctly as I have found no examples of anyone using the sensor on the Analog pins. Can some one with better code knowledge take a look and see if I have it done right.
Thanks.

Code is attached as it's too long to post :wink:

Test07WithMomentaryPulseARRAY.ino (9.28 KB)

Don't make my head spin : What Kind Of Temperature Sensor Would be best - #30 by Koepel - Sensors - Arduino Forum

Koepel:
Don't make my head spin : What Kind Of Temperature Sensor Would be best - #30 by Koepel - Sensors - Arduino Forum

Sorry for the "Head Spin" Koepel, :wink:
Say I checked out a tutorial page on that I.C. 12C bus, WOW! Never knew such a thing even existed. Is it similar to the Shift registers? Watching the irradiation video it seems like it may even be better in many ways?

Koepel,
It must be coded wrong because the Button inputs that are also connected to the Analog pins that are set as digital pins no longer work.
There is also a light on the Arduino that flashes constantly labeled "RX"
The LDR still seems to be functioning normally though and that too is on the Analog pins at pin A0

I have not connected the DS18B20 temperature sensor yet though, first I wanted to make sure the new sketch was not going to mess with anything which it seems to be.

Ok I hooked up the Temperature sensor and it does' to be both reading in the temperature according to the serial monitor and my buttons characters are still being sent but he buttons no longer seem to read in unity 3D.
Now I realize that last part may be a unity related issue but maybe someone here knows.?

If I comment out this part of the Temperature Sensor Data then my buttons seem to work fine so there is definitely a conflict in how I have that coded.

void loop()
{
  //Serial.print("Requesting temperatures...");
  /*sensor_incar.requestTemperatures();
  Serial.println("done");
  Serial.print("Incar");
  Serial.println(sensor_incar.getTempCByIndex(0));*/

  
   
  // read the new light value (in range 0..1023): 
     int sensorValue = analogRead(lightSensorPin);
     // if the value changed by 10
     if(lightSensorValue - sensorValue > 10 || sensorValue - lightSensorValue > 10){
         lightSensorValue = sensorValue; // save the new value
         float p = lightSensorValue * (100.0 / 1023.0);    // make the value to range 0..100
         // the Parentheses may be for compiler optimization idk  
         Serial.println(p); // send it to unity
     }