An amateur radio enthusiast wreaked havoc on the operation of planes, trains, a hospital and shopping centres in a "juvenile prank".

Jamie Corrigan was just 17 when he began using his home equipment to tap into the radio frequencies of Edinburgh Airport's air traffic control, Network Rail, Edinburgh Royal Infirmary, Edinburgh Castle, NSL Services Group and Westside Plaza and Cameron Toll shopping centres.

A trial heard he made repeated transmissions causing fear, alarm and potential endangerment, as well as a number of offensive and abusive remarks, over a nine-month period from June 2014.

Corrigan, now 20, earlier pleaded guilty at Edinburgh Sheriff Court to charges of culpable and reckless conduct.

On Friday, sheriff Frank Crowe accused him of "outrageous conduct" and placed him on a six-month restriction of liberty order to remain in his home between 10pm and 6am.

Corrigan was also ordered to forfeit most of his equipment.

Sheriff Crowe heard Corrigan had a "complex psychological history" and had an appointment with a representative of the Prince's Trust later in October to see if anything could be done to use his skills.

He said he would like to encourage Corrigan to cooperate with the trust rather than do mindless unpaid hours of work.

"He needs to be doing something intellectual," the sheriff said.

The trial had earlier heard Corrigan's calls on the air traffic control frequency at Edinburgh Airport interfered with the safe movement of aircraft and emergency vehicles, compromising the safety of the airport.

Network Rail staff heard sounds of an alarm and offensive remarks and, on one occasion, an attempt was made to redirect moving trains, interfering with the safe movement of rail stock.

Edinburgh Castle received a call implying there was an explosive device there, and calls to Edinburgh Royal Infirmary interfered with the movement of medical staff and equipment.

NSL Services Group received repeated transmissions uttering threats of violence and sexually abusive and offensive remarks, and the two shopping centres were plagued with offensive and abusive remarks.

One call to the Westside Plaza prevented security guards contacting the emergency services for an injured person.

Defence solicitor Andrew Houston told sheriff Crowe that Corrigan had "perceived it as juvenile pranking" and was "uncomfortable and embarrassed about what he had done and didn't want to acknowledge the seriousness of his actions".

Mr Houston added: "He does realise these offences harmed people but finds it extremely difficult for him to express himself in difficult situations".