# Do lone pairs contribute towards the pi electron count of heterocycles?

I'm not able to understand how the following compounds are aromatic.

When should the lone pairs on heteroatoms be taken into consideration when counting the number of π electrons?

Only count the lone pairs/ pi-bonds/ groups which are participating in conjugation and ignore them in all other cases.

For example, in compound 2 (thiophene), there are two lone pairs on sulfur.

One lone pair (brown) is in a p-orbital, and hence participates in conjugation with the two π-bonds. The other lone pair (blue) is pointing outwards from the ring in an $\mathrm{sp^2}$ orbital. This lone pair is orthogonal, or perpendicular, to the π-system and hence cannot take part in conjugation. In total there are six π electrons, and the compound is therefore aromatic.

1. The Nitrogen atom is already an $$\mathrm{sp^2}$$ hybridized atom, so its lone pair does not take part in conjugation
2. The sulfur atom is $$\mathrm{sp^3}$$ hybridized, it has two lone pairs, so only one of its lone pair will take part in conjugation for it to be $$\mathrm{sp^2}$$ hybridized atom
3. $$\ce{N}$$ bonded to $$\ce{H}$$ is $$\mathrm{sp^3}$$ hybridized and has its lone pair taking part in conjugation, thus its lone pair counted as 2 pi electrons. the lone pair of the $$\mathrm{sp^2}$$ hybridized $$\ce{N}$$ atom is not pi electrons
4. Lone pair on $$\ce{S}$$: one pair is pi electrons, lone pair on $$\ce{N}$$: not pi electrons