A peripheral or device is a separate mechanism (always including some electronic hardware, but often also some mechanical constituents) attached to a computer. They are often divided into the actual device, and a device controller which is directly attached to the computer, and mediates between it and the actual device.
They are usually attached to a computer to pass data in and out of the computer - either to secondary storage which is permanently accessible; some other form of data storage, intended for off-line storage (e.g. magnetic tape); or communication, either to users or other computers, etc. A few device types (such as real-time clocks) perform non-I/O functions.