KERNERSVILLE, N.C. — Timothy Scott Swaim, a former Kernersville fire marshal, pleaded guilty today to allegations that he repeatedly took nude photos of a 15-year-old girl and attempted to get her to perform sexual acts on camera.

Swaim, 47, of the 3700 block of Flat Rock Road in Kernersville entered guilty pleas in Forsyth Superior Court to first-degree sex exploitation, attempted first-degree sex exploitation and taking indecent liberties with a child. The offenses that Swaim was charged with occurred in the fall of 2008.

Judge David Hall of Forsyth Superior Court sentenced Swaim to a minimum of seven years and six months to a maximum of 11 years in prison. When he is released from prison, Swaim will have to register as a sex offender for a period of 30 years.

Swaim resigned his position April 19 as fire marshal of the Kernersville Police Department, citing personal reasons. He had held the job for 18 years.

Swaim was arrested April 29.

According to Assistant District Attorney Kia Chavious, Swaim took numerous nude photos of two girls, when they were 15 and 16. In one instance, he took nude or partially nude photos of the girls at the Kernersville Fire Department, where the girls were in or on fire trucks, Chavious said.

He also took nude photos of the girls painting themselves after taking them to buy painting tools at an adult-oriented store, and he took nude photos of them while they were hiking, Chavious said.

Chavious said Swaim also had previously taken pictures of the 16-year-old girl engaging in sexual acts with other teenage girls and he had encouraged the 15-year-old girl to also engage in sexual acts with the 16-year-old girl. The 15-year-old girl refused and became increasingly uncomfortable, she said.

The 15-year-old girl met Swaim through the other girl, with whom she had become close friends, Chavious said. Swaim told the girl that she should take nude photos because guys she might be interested in romantically would expect that, she said.

The investigation began in September 2011 when the girl, who was then a student at a North Carolina college, told her guidance counselor that Swaim had taken photos of her when she was 15. The counselor contacted the FBI, which began investigating. The State Bureau of Investigation took over the investigation and in late April executed a search warrant for Swaim’s house.

Chavious said SBI agents found numerous photos of child pornography in the house. They also found videos of the 16-year-old girl engaging in sexual acts with other girls.

Swaim told authorities that he didn’t believe he was doing anything wrong and that he thought that the 15-year-old girl was actually 16, which is the age of consent in North Carolina for sexual intercourse.

Swaim’s wife and the 16-year-old girl refused to cooperate with authorities in the investigation, Chavious said.

George Cleland, Swaim’s attorney, said Swaim has taken responsibility for his actions by entering the guilty plea and that he has a long history of public service in Kernersville.

John Wolfe III, the town attorney for Kernersville, testified Wednesday. He emphasized that he was not speaking on behalf of the town and told the court that Swaim did a good job as fire marshal and often went beyond the call of duty to protect Kernersville residents.