He got support, second chances, and scholarships that helped him get an education. Obama's father left when he was 2.
"A lot of children don't get those chances. There is no margin for error in their lives," the senator from Illinois said.
"I resolved many years ago that it was my obligation to break the cycle - that if I could be anything in life, I would be a good father to my girls," added Obama, whose daughters, Sasha and Malia, and his wife, Michelle, sat among the congregation.
Obama's appearance at the Apostolic Church of God on the South Side of Chicago was his first address at a church since he ended his membership at Trinity United Church of Christ.
He left Trinity, where he had worshiped for 20 years, after controversial remarks there by his former longtime pastor and others came to light.
Obama frequently emphasized the importance of God in his life and ended the speech by asking the congregation to "Pray for me. Pray for Michelle."
Obama often speaks about the importance of parental involvement. In Washington, he sponsored legislation to get more child support money to children by offering a tax credit for fathers who pay support, more efficient collection, and penalties for fathers who do not meet their obligations.
The issue adds to his family values credentials and lets voters see him delivering a stern message to black voters.
"We can't simply write these problems off to past injustices," Obama said yesterday.
"Those injustices are real. There's a reason our families are in disrepair, and some of it has to do with a tragic history, but we can't keep using that as an excuse."
Obama urged black parents to demand the best from themselves and their children.
He compared it to his presidential campaign and early comments from black voters who said they liked him but did not think a black man could ever be elected president. He said they were admitting defeat before the competition had even begun.
"That was when I wasn't black enough. Now I'm too black," he said in a joking aside.
He said parents who proudly tell him their child gets great grades, all B's, should encourage them even more.
"All B's? Is that the highest grade?" Obama said. "It's great that you can get a B, but you can get a better grade. It's great that you've got a job, but you can get a better job."
Obama is scheduled to campaign today in Michigan, a key state in his November contest with Republican John McCain.