DALLAS — President Obama said Saturday that the gunman responsible for killing five Dallas police officers was a “demented individual” who does not represent black Americans any more than a white man accused of killing blacks at a church in Charleston, South Carolina, represents whites.

“So we cannot let the actions of a few define all of us,” Obama said from Warsaw, Poland, where he attended a NATO summit.

The president said he would visit Dallas in a few days to pay respects and mourn. He also planned to convene a White House meeting next week with police officers and community and civil rights activists to talk about next steps.

It was the third time in as many days that Obama has spoken about the fatal police shootings of black men in Louisiana and Minnesota that were immediately followed by a sniper attack in Dallas that killed five police officers Thursday night. Seven officers and two civilians were also injured.

The Dallas attack layered new anxiety onto a nation already divided about guns and how police treat African-Americans.

The black Army veteran who carried out the sniper slayings donned a protective vest and used a military-style semi-automatic rifle, officials said.

Micah Johnson was killed by a robot-delivered bomb Thursday after the shootings, which marked the deadliest day for U.S. law enforcement since the Sept. 11, 2001, terrorist attacks.

In all, 12 officers were shot just a few blocks from where President John F. Kennedy was slain in 1963.

In Georgia, Missouri and Tennessee, authorities said gun-wielding civilians also shot officers in individual attacks that came after two black men were killed this week in Louisiana and Minnesota. Two officers were wounded, one critically.

“America is weeping,” said Rep. G.K. Butterfield, head of the Congressional Black Caucus, reflecting mounting despair.

President Barack Obama and Texas Gov. Greg Abbott asked for the public’s prayers. In a letter posted online Friday, Abbott said “every life matters” and urged Texans to come together.

“In the end,” he wrote, “evil always fails.”

Johnson, 25, had amassed a personal arsenal at his home in the Dallas suburb of Mesquite, including bomb-making materials, rifles, ammunition and a journal of combat tactics, authorities said Friday.

He followed black militant groups on social media, including one that posted a message Wednesday encouraging violence against police.

Johnson was a private first class with a specialty in carpentry and masonry. He served in the Army Reserve for six years starting in 2009 and did one tour in Afghanistan from November 2013 to July 2014, the military said.

When Johnson was accused of sexual harassment by a female soldier in Afghanistan, he was sent back to the U.S. with the recommendation he receive an “other than honorable” discharge, but he later got an honorable discharge, said Bradford Glendening, a military lawyer.

In addition to the five slain officers, seven officers and two civilians were wounded.

The episode began Thursday evening while hundreds of people were gathered to protest the police killings of two more black men: Philando Castile, who was fatally shot near St. Paul, Minnesota, and Alton Sterling, who was shot in Louisiana after being pinned to the pavement by two white officers.

After shooting at the Dallas officers, Johnson tried to take refuge in a parking garage and exchanged gunfire with police, Police Chief David Brown said.

The suspect described his motive during negotiations and said he acted alone and was not affiliated with any groups, Brown said. Police initially suspected more than one shooter.

He said he wanted to exterminate whites, “especially white officers,” officials said.

In Washington, the nation’s top law enforcement official, Attorney General Loretta Lynch, called for calm, saying the recent violence can’t be allowed to “precipitate a new normal.”

Lynch said protesters concerned about killings by police should not be discouraged “by those who use your lawful actions as a cover for their heinous violence.”

The other attacks on police included a Georgia man who authorities said called 911 to report a break-in, then ambushed the officer who came to investigate. That sparked a shootout in which both the officer and suspect were wounded but expected to survive.

In suburban St. Louis, a motorist shot an officer at least once as the officer walked back to his car during a traffic stop, police said. The officer was hospitalized in critical condition.

A Tennessee man accused of shooting indiscriminately at passing cars and police on a highway told investigators he was angry about police violence against African-Americans, authorities said.

Elsewhere in Texas, police shot and killed a man early Saturday after he was spotted standing in a Houston road with a revolver. Authorities said officers told the man to put down the weapon, but he instead pointed it in the air, then at the police.

Video from Thursday in Dallas showed protesters marching along a downtown street about half a mile from City Hall when shots erupted and the crowd scattered, seeking cover. Officers crouched beside vehicles, armored SWAT team vehicles arrived and a helicopter hovered overhead.

Marcus Carter, 33, was in the area when people started running toward him, yelling about gunshots. Carter said the first shot sounded like a firecracker. But then they proceeded in quick succession, with brief pauses between spurts of gunfire.

“It was breaks in the fire,” he said. “It was a single shot and then after that single shot, it was a brief pause,” followed by many shots in quick succession.

The mayor said one of the wounded officers had a bullet go through his leg as three members of his squad were fatally shot around him.

“He felt that people don’t understand the danger of dealing with a protest,” said Rawlings, who spoke to the surviving officer. “And that’s what I learned from this. We care so much about people protesting, and I think it’s their rights. But how we handle it can do a lot of things. One of the things it can do is put our police officers in harm’s way, and we have to be very careful about doing that.”

Four of the dead were with the Dallas Police Department. One was a Dallas Area Rapid Transit officer.