Project: button controls RGD LEDs which change color based on ds18b20

(deleted)

One weird part is, that my code can be compiled within the Arduino program, but the moment I put it in circuits.io it says there is an error.

First question is why you are doing that.

Second is what does it say the error is?

Third question is why are you asking about something that happens in/on circuits.io here?

(deleted)

The error is in one of the last lines of codes (in the first part of code I posted):

But we still don't know what the error is.

In the first part it states that this piece of code ... shows an error (which I can't seem to find out, why?)

Again, we don't know what the error is, but I can guess that circuits.io doesn't know anything about that library.

(deleted)

Your circuit shows 4 resistors for an LED with 3 color pins. That is one too many. The common leg does not need a resistor.

The DS18B20 appears to be connected to analog pin 0, while the code says that the DallasTemperature bus is using digital pin 7, so the temperature sensor will not be found.

Do you really need 12 bit resolution?

You do not get temperature from a DS sensor using analogRead(). Nothing happens after a return statement, anyway, so the code following the return statement in the (stupidly named) sensorValue() function is noise.

The noise is trying to read the state of a switch that you do not show in the circuit diagram.

Should I go on, or do you want to take a crack at fixing this stuff first?

(deleted)

Add some ( )s here:

if( (tempC == 65) && (tempC == 75) && (tempC == 85) && (tempC == 95)){

How can one variable be four values all at the same time?
Perhaps you meant || so if any one was true it would execute the code that follows?

You asked about the 12 bit resolution, but don't really know what other values would be suiting in my case? I thought a high resolution would only be better for detecting the temperature and make the RGB LEDs shift more gradually in color, please correct me if I'm wrong.

The resolution will differentiate between 15.5 degrees and 15.6 degrees. If that matters, then 12 bit resolution is fine. I doubt the user will be able to tell the temperature by looking at the color of the LED(s).

So if I delete this 'noise' bit, the Arduino won't try reading the non-existing switch?

The "noise" is everything after the return statement.

The function should be called getTemperature() since that is what it does.

After the call to getTemperature(), you should put the code to set the LED color.

analogWrite(bluePin, blueTemp);}

analogWrite only supports 8 bit resolution, the 12 bit discussion seems kind of moot.

(deleted)

(deleted)

In Reply #10, the suggestion was to change && to || (it's shift \ on my keyboard) so the if ( ) evaluates as true if any of the 4 temperatures are met. Not ALL of them at the same time, which is what && requires.

(deleted)