Apple recently launched a replacement program for a small percentage of iPhone 5 that are affected by faulty sleep/wake button mechanism. If you’re one of the unfortunates, you can make do by using AssistiveTouch while you’re on your way to the nearest Apple Repair Center.
To activate AssistiveTouch, go to Settings > General > Accessibility and under AssistiveTouch, turn on the switch for AssistiveTouch.
Once AssistiveTouch is activated, a virtual button will float on the screen at all time. You can drag the button to a corner that is appropriate for your usage.
Lock the Screen
To lock the screen with AssistiveTouch instead of the sleep/wake button, tap on the virtual button. On the AssistiveTouch panel, tap Device and then tap Lock Screen.
To take a screenshot with a faulty sleep/wake button, call up AssistiveTouch panel by tapping on the virtual button. Tap on Device icon, then tap on More, and finally tap the Screenshot icon to capture the current screen.
Power off iOS device
Turning off your iPhone using AssistiveTouch is similar to locking the screen. Tap the Device icon, and then tap and hold the Lock Screen icon until the usual “Slide to Power off” screen appears.
To power on your iPhone without a working sleep/wake button, simply connect your iPhone to a power point or to your Mac via USB.