Eight months after graduating and working in industry, I came to the same conclusion as you: that I preferred writing code to working in the mechanical world. I started learning Java and wrote an Android app. I'd stay up late at night and on weekends pouring over examples and hacking stuff together. Six months into doing that I got an interview at my current employer. I got the job. That was two years ago and it's been one of the best decisions of my life.
The key to doing it:
1) Prove to yourself and others that you want to be a programmer, that you actually enjoy writing code for hours a day
2) Have something to show that proves that
3) Find a company (like I did) that is more interested in finding people who know HOW to think rather than WHAT to think. As engineers you and I are very good at solving problems. Find people who care about that rather than the programming languages you know
4) Once a company takes a chance on you, seize it and run like crazy. Learn as much as you can. In a year or two you can be highly skilled and highly employable in this field.
Best of luck!