A self-powered lock, comprising: a housing; a lock bolt movable manually between a locked position in which at least a portion of the lock bolt extends outward of the housing and an unlocked position in which the portion of the lock bolt is retracted within the housing; a motor in the housing, the motor having a rotatable output gear; a rack gear engaging the rotatable output gear; a pin; a manually operable electricity generator generating electricity upon manual actuation by the user, the electricity generator electrically connected to the motor to supply electricity thereto for operating the rotatable output gear; a lever arm movable between disengaged and engageable positions and operatively coupled to the lock bolt to move the lock bolt between the locked and unlocked positions; and a rotary element engageable with the lever arm in the engageable position thereof, wherein rotation of the rotary element when the rotary element is engage with the lever arm moves the lock bolt between the locked and unlocked positions, wherein the pin normally blocks the lever arm from moving from the disengaged position to the engageable position, and when the motor is actuated by electricity from the electricity generator, the rotatable output gear moves the rack gear and the pin to unblock the lever arm and thereby allowing the lever arm to engage with the rotary element to allow a user to rotate the rotary element to move the lock bolt between the locked and unlocked positions; and wherein the pin is a spring biased pin mounted within the rack gear and having a portion extendible outward of the rack gear under a spring bias and is biased back into a position blocking the lever arm when the rotary element moves the lock bolt to the locked position. a housing; a lock bolt movable manually between a locked position in which at least a portion of the lock bolt extends outward of the housing and an unlocked position in which the portion of the lock bolt is retracted within the housing; a motor in the housing, the motor having a rotatable output gear; a rack gear engaging the rotatable output gear; a pin; a manually operable electricity generator generating electricity upon manual actuation by the user, the electricity generator electrically connected to the motor to supply electricity thereto for operating the rotatable output gear; a lever arm movable between disengaged and engageable positions and operatively coupled to the lock bolt to move the lock bolt between the locked and unlocked positions; and a rotary element engageable with the lever arm in the engageable position thereof, wherein rotation of the rotary element when the rotary element is engage with the lever arm moves the lock bolt between the locked and unlocked positions, wherein the pin normally blocks the lever arm from moving from the disengaged position to the engageable position, and when the motor is actuated by electricity from the electricity generator, the rotatable output gear moves the rack gear and the pin to unblock the lever arm and thereby allowing the lever arm to engage with the rotary element to allow a user to rotate the rotary element to move the lock bolt between the locked and unlocked positions; and wherein the pin is a spring biased pin mounted within the rack gear and having a portion extendible outward of the rack gear under a spring bias and is biased back into a position blocking the lever arm when the rotary element moves the lock bolt to the locked position.