Wrote main logic
Led management added
Moved main logic to thread