Note:This is not simulation circuit . This project will not work on proteus , because proteus does not have any real temperature .
The code description is below the code, scroll down please
This is basic temperature representator rather than thermometer . It measure temperature in negabinary which is represented by two led yellow and green .
What is Negabinary and how it is represented on LED ??
Nega binary is basically negative binary To understand negabinary, you should know binary first . Let's take an example of binary . Let's say we have a binary number 1101011 the equivalent decimal number of this binary is 107 because 1x26+1x25+0x24+1x23+0x22+1x21+1x20=107 . But in negabinary it has power of negative 2 rather than positive power of 2 .Let's take same example again to convert 1101011 to nega binary we have to add negative power like 1x(-2)6+1x(-2)5+0x(-2)4+1x(-2)3+0x(-2)2+1x(-2)1+1x(-2)0 and which is equal to 23 and hence yellow LED blink 2 times and red blink 3 times .. sorry for above circuit is not like this . and sorry this thermometer is not easy to read temperature but you can represent the output in different way like you can fed this with serial thermometer . or etc .
Another cool feature of this thermometer is power saving mode . Look i have included sleep.h header file which is inside avr folder of atmel studio . The thermometer goes to sleep mode whenever it is not measuring the temperature ie when LED goes off for certain time then the microcontroller goes to sleep mode so that we can save the power and the battery will be extended a little bit more .The routine for the sleep mode is here .
This enables the watchdog timer, and the parameter n sets the watchdog timer prescaler. the value 0 represent 16 ms of delay and 9 represents 8 second delay . And watchdog interrupt service routine ISR ( ISR(WDT_vect)) simply disable the watchdog timer and save the power . This watch dog timer feature is very important feature of microcontroller and used widely to save power which is the major design issue of the modern electronics and embedded design .
Another concept used in this project is internal ADC of microcontroller . There is already a long tutorial about the internal analog to digital converter of AVR you can learn more about AVR ADC from this link https://www.electronify.org/learn-microcontrolleravr/adc
and if you have not idea about the interrupt and interrupt service routine or ISR you can learn about this from this link https://www.electronify.org/learn-microcontrolleravr/interrupts
If you have any question about this project or have any errors on compiling on atmel studio6 please comment below . And if you think this is useful project don't forget to share this project .