If you post your code as described in How to get the best out of this forum, more forum members will read it and likely offer alternative solutions.
Post your schematic in CAD or a picture of a hand drawn circuit in jpg or png. PLEASE- not a pretty Fritzing picture.