The improper bush-button event handling is likely to cause the problem. One way to properly react to the external environment signals could be constant polling or using interrupts. With constant polling, all the time is spent on the checking the status of the button. With interrupts, the program is executed as it should, and only if interrupt happens - the execution jumps to the interrupt subroutine, executes it, and goes back to the main code where it left off.
In your case, you can use pin 7, for example, for push button signal. It can have a function of INT0. Read Section 9. Interrupts of the datasheet - it is straight forward.
I do not completely understand what your program should do, but I will try to convey the general approach of using subroutines:
volatile bool pressed = false;
MCUCR |= (1<<ISC01 |1<<ISC00); // set INT0 to interrupt on rising edge of pin7
sei(); // enable global interrupts
if (pressed) then do something; //You can disable interrupts here so your code is not interrupted by cli();
pressed = false; // reset the state
else do something else;
// you can re-enable your interrupts here by sei();
// only happens when the change on pin 7 is from LOW to HI
pressed = true; // update the pressed status
If you want to use pin6 for push button, you should enable the PCINT1 instead of INT0 and change the ISR to handle the PCINT1 interrupt. In this case, pin 6 will react on voltage toggle (from HI to LOW, or the other way) and you can not discriminate rizing/falling edges. In that way, you must read pin6 within the instruction subroutine to know if it is hi or low.
I would suggest to stop the calculations in the Temp() function after the
average = SERIESRESISTOR / average;
line due to the fact that you have only three operating modes for the LED. Thus you can, back calculate the average value that makes your steinhart value to be, for example >30. This way, all other values greather/smaller than that value will also fall under the same condition depending on whether average/steinhart are directly/inversely proportional.
When you determine the three ranges of raw average values you can use them directly in the Mode() function. Eventually, you can optimize you code even further, by performing monotonic read instead of burst reads. If you keep a buffer, you do only one addition of the most recent sample and subtracting the oldest sample. For this you will need two pointers and one memory for to store sum, but you will not need to do nSamples additions:
sum += newSample;
sum -= oldestSample;
average = sum/numSamples;
update pointers to the memory for oldest sample and for the feature sample;