Function was not declared in this scope - compile error

Lots of details missing. What version of the IDE are you using? What errors are you getting?

// THIS IS A TEST FUNCTION  //
           
void heat()

Embedded in loop. Your crappy indentation isn't helping. Use Tools + Auto format to straighten that mess up.