You need to learn to fail quickily as possible and often as possible. Everything you start a project and it doesn't work out you need to go and celebrate. You did something most people don't... that is TRY... Just keep working/failing/learning and one of these times something will happen and it won't break and it'll work and you'll look back at your post like... "woah, I can't believe I wrote that"
100% agree with this, with one proviso. You need to learn from your failures. Keep a journal of all your experiments (for that's what they are), and what you learned from them. Each lesson brings you closer to success.
I know this sounds like typical self improvement BS, but it works.
Embracing failure is one the reasons Silicon Valley venture capital firms do much better than us miserable Europeans - investors here won't touch an entrepreneur who's been through a massive failure. Investors over there often won't take them seriously until it's happened at least once.