President Obama speaks during a visit to Mooresville Middle School in Mooresville, N.C. on June 6. The visit is part of Obama's "Middle Class Jobs & Opportunity Tour." (Kevin Lamarque/Reuters)

President Obama journeyed to a high-tech middle school here Thursday to announce plans to expand broadband and wireless Internet access to each of the nation’s schools and libraries.

Lamenting that the United States had fallen far behind rivals such as South Korea in connectivity, Obama said a new initiative called ConnectED would connect 99 percent of the nation’s students with high-speed Internet within five years.

“In a country where we expect free WiFi with our coffee, why shouldn’t we have it in our schools?” Obama said in a speech at Mooresville Middle School here. He added, “We can’t be stuck in the 19th century when we’re living in a 21st-century economy.”

Obama said he envisions digital learning in classrooms nationwide and hailed Mooresville Middle School — where every student here now has a laptop — as a national model.

Obama was decidedly upbeat as he escaped scandal-obsessed Washington for this suburb of Charlotte, the host city for his 2012 Democratic National Convention. He said he was encouraged to visit at the end of the school year because “everybody’s in a good mood.”

Addressing a few hundred people who had been waiting on their feet in a hot and steamy gymnasium for more than an hour, Obama volunteered some advice: “Bend your knees a little bit when you’re standing,” he said. “I’m just giving you a tip so you don’t faint, which happens all the time, and it’s really embarrassing.”

By the end of his remarks, though, two people appeared to have fainted and required medical attention.

Spotted among the crowd of students, educators and political supporters was actress Claire Danes, who has been shooting season three of the Showtime drama “Homeland” in Charlotte. Danes sat in the front row of a VIP section, and when Obama saw her on the rope line he kissed her on the cheek.

Obama’s broadband plan is among several executive actions he has taken in recent months that are designed to help stimulate the economy. Mooresville is the third stop on Obama’s “Middle Class Jobs & Opportunity Tour,” which he launched last month with visits to Austin and Baltimore.

Obama called on the Federal Communications Commission to use its existing E-Rate program, which is funded through a surcharge on telephone bills, to help advance the broadband goal. He also instructed other parts of the federal government to redirect resources toward classroom technology and teacher training.