Taking the pill

If I'm going to have sex and don't want to use protection, can I take the pill for the first time and have sex with it being effective or not?