Problem Combining Multiple Codes

In C/C++ you can't declare a function inside another function. You have the changeLED and heartBeat functions inside the loop() function. Move them so that they are outside it.

Pete