Added circuit schematic and revised code