An accelerometer in a smartphone measures changes in velocity or speed over time. It does this by detecting movements in the X, Y, and Z axes and converts them into analog voltage outputs. This information is then used to determine the orientation of the smartphone and rotate the screen accordingly.