Can you tell me how the heart know to take blood from the coronary arteries?

Pressure. The blood moves from an area of higher blood pressure to an area of lower BP. That's why, in order to be alive, you must have blood pressure!