I'm using a 2222a transistor as a switch. When it turns on the voltage drops from 3.3v to 2.9v. Why is there such a voltage drop? How can I fix that?
What voltage, where are you measuring this.
Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.
I'm assuming you're talking about the voltage drop between the collector and the emitter.
I'm afraid there's nothing you can do. It's called the Collector-Emitter Saturation Voltage or Vce(sat). It is an important factor when choosing a transistor and is specified in all transistor datasheets. Here's is the 2N2222 transistor datasheet:
You can see that Vce(sat) is specified as 0.4V when the current is 150mA. 0.4V is exactly what you have measured.
All transistors drop voltage, because they are basically diodes. This voltage drop is also dependent on the current going through the transistor. The more current that goes through it the more voltage the transistor drops. You can see in the picture that at 500mA the voltage drop increases to 1.6Volts.
If you want lower voltage drops you should use a MOSFET. They also drop voltage but much lower. To calculate a MOSFET's voltage drop multiply its RDS(on) by the current going through it.
If you choose a MOSFET make sure that it will fully turn on with a 5V (or 3.3V) gate signal. Those are called logic level MOSFETs.
You really need to post your circuit. If you're trying to switch on the high side, then you have the wrong type of transistor, and an N-channel mosfet might be even worse.