The boy, from Rotherham, who cannot be named for legal reasons, was also ordered to pay £100 compensation at a hearing at Sheffield Youth Court on Wednesday, November 23.
The court heard the boy's parents handed their son into the police after recognising him from a media appeal.
The teen who was handed a nine-month Youth Referral Order, admitted to pushing the rock off the bridge in Kilnhurst near Swinton as a train approached on Saturday, September 10, causing £500 worth of damage.
The court was told the rock smashed through the glass window section, which displays the destination of the service, and ended up in the cab, narrowly avoiding the driver who was showered with glass and debris from the impact.
The train had to be stopped and taken out of service for repairs, causing delays to the rail network
Investigating officer Detective Constable Ian Grice said; “Hopefully, the defendant now realises the severity of his recklessness; the potentially fatal consequences and the implications for others because of this mindless act.
“It was sheer luck that the driver of the train came to no harm. Nevertheless this was still a terrifying experience.
“Any incident which endangers rail staff and the travelling public will be investigated robustly and as in this instance, offenders will be identified and brought before the courts.”
A spokesman for Northern said: “Thankfully in this case our driver was not seriously injured, but the incident highlights the potential consequences of such reckless action.
“And it is not just the risk of injury to rail staff and our customers that results from incidents of this nature; aside from the cost of repairs, there is also the knock-on effect of having to take the damaged train out of service and the subsequent delays this causes – impacting on hundreds of passengers.
“We will continue to work with British Transport Police to identify those who put the safety and security of our staff and customers at risk and will also seek to work with schools across our network to educate children about the potential dangers of such behaviour.”