It is understood the boys were trying to get to the man's neighbour in the flat above, but mistakenly banged on the other man's window before opening it.
Prosecuting at Preston Crown Court, Claire Brocklebank said at around 2.40am on November 14, 2019, there was a group of three boys outside the man's home and that they were shouting to the resident upstairs.
She added: "They opened his window, at which he confronted them and they ran away.
"He started to chase them but as he did he saw one defendant was swinging some nunchucks, as he calls them.
"At this he ran back home, climbed in through the window they had opened, picked up a pan and brush set and went outside to chase the males away."
Police were called to the scene and found the teenagers crouching down behind a van and attempting to walk away.
A yellow JD Sports bag found close by contained a machete.
A second machete was found in a nearby alley behind a gate, and nunchucks were found when police searched the third boy.
DNA was matched to Nathaniel Lawrenson, 18, of Redcar Avenue, Ingol, Preston, who has since admitted possession of an offensive weapon.
One other youth, who cannot be named for legal reasons, has been given a youth referral order by magistrates, and the other faces a trial at the youth court.
In a victim statement the man said he feared he would be "killed or seriously injured" and has been left scared and wanting to move away.
Defending Lawrenson, Barbara Webster said he had mental disabilities including ADHD and that his parents had attended court to support him.
She said: " The offence took place when he was only 16.
"It appears he's had difficulty through the education system. It also appears difficult for Mr Lawrenson to have some form of stability.
"What transpired in 2019, a few days before the offence occurred, was he had a rejection from Myerscough College and it transpired thereafter that his life spiralled out of control.
"He tries to ingratiate himself and tries to become 'one of the boys' at the time. That's no longer his mindset."
The court heard since committing the offence he had appeared before the youth courts for other matters but had made good progress.
Judge Graham Knowles QC acknowledged Lawrenson had previously been identified as at risk of exploitation.
Ordering forfeiture of the weapons, he said: "On November 14, 2019, you were one of three boys who carried out a terrifying raid on somebody's home, in reality.
"The man tried to chase you and the others away but ended up fleeing in fear for his own life.
"When the police arrested you you had nothing to say to them in your interview.
"You are 18 now, you were 16 approaching 17 when you committed the offence.
"Because you are now, in the eyes of the law, an adult I have to apply the law, for the purposes of sentencing, that applies to adults.
"I accept if you went into custody you would be exploited and you would be damaged and that all the progress you have made...since you committed this offence would be squandered."
He imposed a three year community order with a rehabilitation activity requirement and a two month curfew.
The Lancashire Post is more reliant than ever on you taking out a digital subscription to support our journalism. For unlimited access to Lancashire news and information online, you can subscribe here.