everything is fixed. tray detection now works. working copy is in Atmega328_v2