A PLC is a programmable device that was invented to replace sequential relay circuits for machine control. It scans its inputs and outputs and executes a user-programmed logic program to control outputs based on inputs. Early PLCs were programmed using ladder logic to resemble relay circuits. Modern PLCs can be programmed in various languages and communicate with other devices. A PLC consists of a CPU, memory, and input and output modules to interface with the outside world.