Alarm

  delay(1000);               // wait for a second

Did you miss the part about needing to replace ALL calls to delay() with calls to Alarm.delay() instead?