What happens to the temperature when an ideal gas is compressed? I am rather confused about this. I know from Charles' law that under constant pressure, the volume of a gas is directly proportional to its absolute temperature i.e.
$$\frac{V_1}{T_1} = \frac{V_2}{T_2}$$
Thus accordingly, during compression, temperature of the gas would decrease. But in Lectures of physics ,vol 1 by Feynman, it is written:

Suppose that the piston moves inward, so that the atoms are slowly compressed into a smaller space. What happens when an atom hits the moving piston? Evidently it picks up speed from the collision. [...] So the atoms are "hotter" when they come away from the piston than they were before they struck it. Therefore all the atoms which are in the vessel will have picked up speed. This means that when we compress a gas slowly, the temperature of the gas increases.

(Constant pressure?) So, this is contrary to Charles' law. Why does this happen? Who is right? Or are they both correct? I am confused. Help.
 A: Consider two devices:
A gas law demonstration apparatus measures temperature and pressure during compression. This device slowly lowers a piston in a thin walled container, resulting in mostly pressure increase with typically less than one degree of temperature increase. 
Compare this with a fire syringe, in which a piston in a well insulated container is hammered down, creating a temperature change high enough to ignite cotton.  
Explanation: The gas law demonstration apparatus is primarily an isothermal compression device (slow and poorly insulated), and the fire syringe is an adiabatic compression device (fast and well insulated.
A process is adiabatic when the system does not exchange heat with its surroundings. This can happen in two ways - either you can insulate the system so well that the heat transfer is negligible or you can )make the process so fast that there is not enough time for heat exchange (All heat transfer mechanisms - conduction, convection, diffusion and radiation - are time consuming). 
Just how fast a process needs to be to be adiabatic depends on how well the system is insulated. If the system is insulated very well, the adiabatic processes can be a lot slower than when the system is insulated poorly. Even if the system is not insulated at all, there is some timescale below which any process becomes adiabatic. For example, the expansion of an air parcel raising in the atmosphere is approximately adiabatic.
In contrast, isothermal processes are necessarily slow as they require heat transfer to remain at the same temperature which is done by being in thermal equilibrium with some reservoir. A process will be isothermal only if it happens on timescales larger than the timescale required for effective heat transfer.
A: You need to read about the Joule-Thompson effect in Wikipedia.  In an ideal gas there is no temperature change upon compression  or expansion.  The only gases that come close to being ideal at room temperature are Helium, Hydrogen and Neon.  They actually slightly cool on compression and heat on expansion at room temperature.  This can be reversed at very low temperatures.  Most non-ideal gases such as nitrogen, oxygen and carbon dioxide do heat on compression and cool on expansion.  With carbon dioxide having the biggest temperature change for a given pressure change. This Joule-Thompson effect is due mostly to Van der Waal forces between the molecules.
A: There's actually not one simple answer to your question, which is why you are a bit confused. To specify your problem fully, you must specify exactly how and whether the gas swaps heat with its surroundings and how or even whether it is compressed. You should always refer to the full gas law $P\,V=n\,R\,T$ when reasoning. Common situations that are considered are:


*

*Charles's Law: The pressure on the volume gas is constant. No work is done by the gas on its surroundings, nor does the gas do any work on its surroundings or piston or whatever during any change. The gas's temperature is that of its surroundings. If the ambient temperature rises / falls, heat is transferred into / out from the gas and its volume accordingly increases / shrinks so that the gas's pressure can stay constant: $V = n\,R\,T/P$; with $P$ constant, you can retrieve Charles's Law;

*Isothermal: the gas is compressed / expanded by doing work on / allowing its container to do work on its surroundings. You think of it inside a cylinder with a piston. As it does so, heat leaves / comes into the gas to keep the temperature constant. As the gas is compressed, the work done on it shows up as increased internal energy, which must be transferred to the surroundings to keep the temperature constant. At constant temperature, the gas law becomes $P\propto V^{-1}$;

*Adiabatic: No heat is transferred between the gas and its surroundings as it is compressed / does work. AGain, you think of the gas in a cylinder with a plunger. This is prototypical situation Feynman talks about. As you push on the piston and change the volume $V\mapsto V-{\rm d}V$, you do work $-P\,{\rm d}V$. This energy stays with the gas, so it must show up as increased internal energy, so the temperature must rise. Get a bicycle tyre pump, hold your finger over the outlet and squeeze it hard and fast with your other hand: you'll find you can warm the air up inside it quite considerably (put you lips gently on the cylinder wall to sense the rising temperature). This situation is described by $P\,{\rm d}V = -n\,\tilde{R}\,{\rm d} T$. The internal energy is proportional to the temperature and the number of gas molecules, and it is negative if the volume increases (in which case the gas does work on its surroundings). But the constant $\tilde{R}$ is not the same as $R$: it depends on the internal degrees of freedom. For instance, diatomic molecules can store vibrational as well as kinetic energy as their bond length oscillates (you can think of them as being held together by elastic, energy storing springs). So, when we use the gas law to eliminate $P = n\,R\,T/V$ from the equation $P\,{\rm d}V = -n\,\tilde{R}\,{\rm d} T$ we get the differential equation:
$$\frac{{\rm d} V}{V} = - \frac{\tilde{R}}{R}\frac{{\rm d} T}{T}$$
which integrates to yield $(\gamma-1)\,\log V = -\log T + \text{const}$ or $T\,V^{\gamma-1} = \text{const}$, where $\gamma=\frac{R}{\tilde{R}}+1$ is called the adiabatic index and is the ratio of the gas's specific heat at constant pressure to the specific heat at constant volume.
A: Gay Lussac's law (of pressure–temperature): $P$ is directly proportional to $T$.
When $P$ increases, $T$ also increases.  When we compress the gas, pressure increases, which means temperature also increases.
A: Compression of gas will have inverse relation to volume but direct relation to temperature bcz of molecular collision regardless of effect being exerted by container or piston.
