From Bulbapedia, the community-driven Pokémon encyclopedia.
Infrared interaction between a Pokémon Pikachu 2 GS and a Game Boy Color
The infrared (Japanese: 赤外線通信 infrared communication) feature allows communication between the Pokémon games and certain accessories. It was first used in the Generation I spin-off game Pokémon Trading Card Game.
In Pokémon Trading Card Game, there's a feature called Card Pop! that takes advantage of the Game Boy Color's infrared port to allow each player to receive a random card. However, using the Card Pop! feature between the same two players is only possible once.
In Generation II, the infrared port at the top of the Game Boy Color allows players to obtain Mystery Gifts via Pokémon Pikachu 2 GS or other Game Boy Colors.
The Pokémon mini also has an infrared port. It uses this to have multiplayer games of up to 10 players (number of players varies per game). The games which utilize this feature are Pokémon Party mini, Pokémon Zany Cards, Pokémon Tetris, Pokémon Race mini, and Pichu Bros. mini.
In HeartGold and SoulSilver, an infrared sensor is used to link the Nintendo DS and the Pokéwalker.
In Black and White and Black 2 and White 2, an infrared-capable feature is accessed via the C-Gear. It is also used in the Battle Subway.