When it came to keeping hungry lions at bay, an old-fashioned scarecrow just wasn't up to the job. So Richard Turere, a 13-year-old Maasai cattle herder, combined rudimentary technology with teenage ingenuity to find another way.

Turere is the inventor of "lion lights", a fence made of a car battery, solar panel and torch bulbs that ensures lions no longer dare touch his father's livestock. The young Kenyan has been lauded as an inspiration after giving a recent TED talk about his invention.

Turere lives in Kitengela on the edge of Nairobi national park. He told how wild animals that migrate from the park are pursued and killed by lions.

"My community, the Maasai, we believe that we came from heaven with all our animals and all the land for herding them, and that's why we value them so much," says Turere, who started herding his family's cattle when he was nine. "So I grew up hating lions so much. The morans are the warriors who protect our community and the livestock, and they're also upset about this problem. So they kill the lions … And I think this is why the Nairobi national park lions are few."

Turere said he tried various ideas for a more peaceful solution, such as a kerosene lamp and a scarecrow. "But lions are very clever. They will come the first day and they see the scarecrow, and they go back, but the second day, they'll come and they say, this thing is not moving here, it's always here. So he jumps in and kills the animals."

But, one night, Turere went to the cowshed with a torch and found that the lions stayed away. "I discovered that lions are afraid of a moving light."

The teenager – who has a knack for making things from scrapyard parts – bought a car battery, motorcycle indicator box, switches, torch bulbs and solar panel, and hooked them together. It worked, and now dozens of lion lights have been rigged up around Kenya.

As a consequence, Turere gained a scholarship to one of the country's top schools, delivered a TED talk in Longbeach, California, last month, and has ambitions to be an aircraft engineer and pilot when he grows up.

"I used to hate lions," he adds, "but now, because my invention is saving my father's cows and the lions, we are able to stay with the lions without any conflict."