So, on the 0-4096 bits
I hope you mean 12 bits. (0 to 4095)
Do I really need to correct that??*sigh
Yes, please, go ahead.
PWM does not make analog voltage output. It makes pulses of VCC output.You could probably wire an LM35 into a circuit that would give the VM 0-5V analog.
40/180*4096 = 910 bits of the 4096 bits in total, which is almost enough to use with the 10-bit range of the Arduino analogue input.
So, on the 0-4096 bits of temperature sensor output, I only want to use from bit 1365 to bit 1980 as my 0-1024 analogue input, then mapped to the 0-255 on the PWM 0-5V output.
Since the DS18B20 is digital, the 10-bit Arduino ADC has nothing to do with this...
Try this - map(X, 1365, 1980, 0, 255); //Not tested or verified!!!...But first, read the raw temperature sensor and "look at" it with the serial monitor to make sure room temperature (or whatever) looks reasonable.
10 bits can be 0 to 1023. Not 1023 bits, MAX VALUE is 1023.12 bits can be 0 to 4095. Divide that by 4 and get 10 bit values.And regular PWM outputs 0 to 100% as 0 to 255 which is 8 bits.You need to map a range from the 12 bit DIGITAL input to the 8 bit PWM, not the 10 bit ADC.
It's only the ADC which is ten bit, but with a twelve bit digital sensor, you're not using the ADC.