Created single function for setting both alarms and error codes.