When I turn the key on

My car wouldn't start yesterday, we tried charging the battery but wouldn't work. We went to a shop and told us the battery was dead so we bought a new one. Once the new one was installed everything was working great but the check engine light came on, why?