what causes check engine light to come on?
A completed circuit. Just kidding.
The car’s computer has recognized a problem with the car. It can be thousands of different things. Go to a local auto parts store like Advance, Pep Boys, Auto Zone, etc. Most of them can scan the computer for free. Get the codes (they are in the form of “P1234” or similar) and post them back here. Then the real mechanics on this board (there are some real experts who give free advice) can help you. They are a fantastic resource. Good luck!
Just to add one thing to mieich’s response: Don’t look at the english translation of the code. No code says. "replace the fuel cap or change the spark plugs. It only reports things like Plug # 3 is not using the normal expected current when tested. While that might end up with a bad plug, or wire or a compression problem etc. Many places don’t trouble shoot and only replace, which can cost you more than finding out what it really is.
a problem with the engine causes the check engine light to come on
Look at this:
And those are only the generic codes. Each manufacturer adds more.
I have a theory that the OBD system is programed with a very sophisticated algorithm that lights up the check engine light the day before your inspection is scheduled;-)