Gardai raided a house in Letterkenny and found cannabis plants growing in a bedroom.
The set-up at 14 Hazelbrook Crescent, Long Lane involved the plants being put in a box with tin foil and powered by a 600 watt bulb.
Gardai arrested Patrick Hughes, 27, at the scene.
Hughes appeared at Letterkenny District Court on charges of cultivation of cannabis and also possession of cannabis on April 14th, 2011.
His solicitor Frank Dorrian said his client had found the seeds in some cannabis he had purchased and had tried to grow them.
He went onto the internet and found instructions about how to carry out the process.
“It was not the most elaborate or well-constructed factory,” said Mr Dorrian.
The court heard that there was a total of six plants in the wardrobe.
The court was told that Hughes of 13 Parkview drive, Letterkenny, had problem with alcohol but was now off it since October.
He had worked for an insurance company in Cork but that job had fallen through and he was now back in Donegal.
Judge Denis McLaughlin said the only reason he was not considering jail sentence was because of the early plea.
He adjourned the case until February 10th to consider allowing Hughes to do 240 hours community service in lieu of six months in prison.