add learning functions to arduino code, implementing learning protocol