Hi. Read please this article
and give us more information.
- What do you mean "I tried in the AtMega"?
- What is your relay modules?
- Give your wiring diagram (may be hand-drawn).
- Give your preformatted and properly pasted code.
It will be easier to help you.