Our dog has the run of the house when I'm home, and she's usually really good at waiting for her walks to go potty outside. But she's not the type of dog to just be let out to do her business, she needs to be walking in order to get anything to happen.
When we leave the house, and at night, we have a baby gate that keeps her in the kitchen area and away from the hardwood floors. She is also trained to a puppy pad, which we keep on the floor in the kitchen while she is kept in there just in case, sometimes she uses it and sometimes she just waits to go outside. Her water and her bed are in the kitchen area too.
Please do not let your dog use the carpet in your house to go potty! Sure, you can clean the surface stains, but the padding underneath gets wet too and you can't effectively clean that. If you let your dog pee on the carpet your house will STINK. There is no way to fix it besides ripping out and replacing the carpeting, and sometimes even the subflooring underneath if it's bad enough.
Your best bet is to take the time to truly housetrain your dog. It takes dedication and consistency, but it will be worth it and your life will be far less stressful when you don't have to worry if the dog messed in the house. Then, for good measure, keep him out of the carpeted areas in your home when you cannot supervise him.