How to identify the number of pi electrons in a conjugated system to calculate the HOMO-LUMO gap with the particle in the box approach? It's my understanding that for a particle in a 1-D box, the change in energy from the HOMO to LUMO can be approximated with the following equation:
$$\Delta E=\frac{h^2 ( N + 1 )}{8 m_\mathrm{e} L^2}$$
I am told that $N$ represents the number of &pi; electrons in the molecule.

If you're studying a molecule like the one shown below and you want to predict the absorption wavelength from UVVIS, would you count all of the &pi; electrons, or just the conjugated ones? It doesn't make much sense to me why you'd want to include the &pi; electrons from the phenyl group next to the neutrally charged Nitrogen because it's not conjugated with the rest of the molecule to the same extent the other phenyl group is, and thus seems like it would be grossly inaccurate to assume that those &pi; electrons contribute the same as the others.
In a very basic first order approximation you can treat dyes with an extended conjugated &pi;-system with the one-dimensional particle in the box approach. I simplified your system and calculated it at the DF-BP86/def2-SVP level of theory. The length of the box is about $L=1.20~\mathrm{nm}$, the following graphic shows it in &Aring;ngstr&ouml;m.



With that there are a number of problems associated. Counting the number of electrons in the &pi;-system should not be among them. Just assume that all non-hydrogen atoms are sp² hybridised. Then count the electrons that occupy &pi;/p-type orbitals. Here is an image of the lowest occupied &pi;-type orbital of that molecule; you can see that the box stretches over the whole molecule. The thumbnail next to it gives you all occupied &pi;-type orbitals and the lowest unoccupied molecular orbital.

&nbsp;



   In this example each phenyl ring contributes six &pi; electrons (12), two sulfurs contribute two each (4), the nitrogen double bond (2), the carbon-carbon double bond (2) and the last nitrogen (2). That makes a total of 22 &pi; electrons.