Coffee grounds do work well to keep ants away from areas you want to keep them away from.
The coffee grounds after they've been brewed put out a strong smell that the ants are repulsed by and the ants will stay away from any areas that the used coffee grounds are placed.
You can spread used coffee grounds around pet bowls where pet food is or any other areas that the ants are trying to get too and the ants will be repelled by the smell of the coffee grounds and will stay away from those areas.
Still it's a good idea to use some ant spray too to kill off any ants that are coming into your house.
I put some used coffee grounds around areas of my house where ants are hanging out and it prevents them from getting into my house so it does work.