Restructured C# code and arduino door code