BANGOR – A Florida man who is charged with causing a trans-Atlantic flight to be diverted to Bangor 18 days ago walked out of a federal courthouse Friday to live under house arrest with his girlfriend’s parents in Matamoras, Pa.

Derek Stansberry, 27, of Riverview, Fla., was released on $20,000 bail to stay with the parents of Jillian Krause.

U.S. Magistrate Judge Margaret Kravchuk said the Pennsylvania location would allow Stansberry to drive, rather than fly, to appearances in U.S. District Court in Bangor.

Stansberry’s conditions of release include wearing an electronic monitor, having a psychological evaluation as an outpatient, not possessing a gun, destructive device or other dangerous weapon, and not traveling outside Pennsylvania without prior approval by an officer with U.S. Probation and Pre-trial Services. He also was required to surrender his passport.

Prosecutors allege that on April 27, Stansberry passed a note to a member of the flight crew that said he had a fake passport. When questioned by federal air marshals, he told them he had dynamite in a laptop in his backpack, according to court documents. The Paris-to-Atlanta Delta Air Lines flight ended up landing at Bangor International Airport.

Stansberry’s travel papers were in order, and there was no dynamite, according to court documents. He has been charged with providing false information and making threats, as well as interfering with a flight crew.

Stansberry told investigators that he took eight Ambien pills before boarding the plane.