Gary Owens, 38, previously admitted a string of firearms offences committed between 1 February and 16 April 2014 at his home in Jamaica Mews.
The offences included manufacturing a prohibited weapon and possessing homemade firearms.
Owens said he had made the weapons in order to commit suicide.
Unemployed Owens, who was said to suffer from depression, said he had built the firearms through a process of trial and error and had bought matches and party poppers to supplement parts he had found abandoned.
He created the weapons in his flat and test fired one in his hallway, where shotgun pellets were found embedded in a door.
Lord Uist said the firearms could have come into the hands of others who could have used them for any purpose they wished.
He pointed out that Owens had a lengthy criminal record and a chronic drug abuse problem, and said Owens had made the devices knowing the harm they could cause.
Advocate depute Susanne Tanner had earlier told the High Court in Edinburgh: "He claimed not to have researched it in any way on the internet saying he had never used a computer in his life."
Defence solicitor advocate Robbie Burnett said of Owens: "He is very much a loner. He tells me he has no real friends. He has been depressed for some considerable time and had on various occasions attempted suicide."
An Edinburgh man who built potentially lethal firearms from items found in the streets and skips has been jailed for five years and nine months.