Energy consumption is an important design parameter for embedded and portable systems. Software-controlled (or dynamic) power management (DPM) has emerged as an attractive alternative to inflexible hardware solutions. However, DPM via I/O device scheduling for real-time systems has not been considered before. We present an online I/O device scheduler, which we call low-energy device scheduler (LEDES), for hard real-time systems that reduces the energy consumption of I/O devices. LEDES takes as inputs a predetermined task schedule and a device-usage list for each task and it generates a sequence of sleep/working states for each device such that the energy consumption of the device is minimized. It also guarantees that real-time constraints are not violated. We then present a more general I/O device scheduler, which we call multistate constrained low-energy scheduler (MUSCLES), for handling I/O devices with multiple power states. MUSCLES generates a sequence of power states for each I/O device while guaranteeing that real-time constraints are not violated. We present several realistic case studies to show that LEDES and MUSCLES reduce energy consumption significantly for hard real-time systems.