Comparator Day/Night Detector

This compact day/night detector uses a comparator in subtract mode to output a redstone signal only when the sun begins to set. Unlike a plain daylight detector that powers during the day, this setup cleanly inverts the signal by comparing sunlight against a half-full container. It is ideal for automatically turning on street lamps in survival bases or triggering command blocks to reset the time in creative worlds.

ClocksBeginnerJava Edition
Comparator Day/Night Detector video tutorial

Video: Daylight Sensor - Minecraft Redstone Tutorial by TT Lemon

How to build it

  1. Place the Comparator in Subtract Mode

    Place your redstone comparator on the ground facing the direction you want your final output to go. Right-click (or interact with) the comparator once so its front torch turns on, putting it into subtract mode.

  2. Attach and Fill the Container

    Place a block with an inventory directly behind the rear input of the comparator; a hopper works best because it only has five slots. Fill the container halfway—for a hopper, put in 2.5 stacks of normal 64-stackable items.

  3. Connect the Side Input Dust

    Place a single piece of redstone dust directly next to either side of the comparator so it feeds into the comparator's side (B) input.

  4. Add the Daylight Detector

    Place your daylight detector adjacent to the redstone dust so it powers that dust line. Alternatively, for an even tighter footprint, you can place the daylight detector directly against the side of the comparator without the dust.

  5. Connect Your Output

    At sunset, the front of the comparator will emit a weak redstone signal. For survival lighting or note block alarms, place a redstone repeater directly in front of the comparator to boost the signal to full strength (15), or place a command block there in creative mode.

How it works

This circuit relies on comparator subtraction logic and container signal strength:

  • Rear Input (Signal A): A half-full hopper (2.5 stacks of items) outputs a constant, fixed redstone signal strength into the back of the comparator.
  • Side Input (Signal B): The daylight detector measures the current sky light level and sends that strength into the side of the comparator.
  • Subtraction Mode: When the front torch on the comparator is lit, it calculates Output = Rear - Side. During the day, the daylight detector's signal is stronger than the hopper's signal, resulting in an output of 0 (off).
  • Sunset Trigger: Just before sunset, the daylight detector's signal drops below the hopper's fixed signal strength. The comparator can finally let a signal through, turning on your street lights or command block right as dusk arrives.

Tips & variations

  • Ultra-Compact Variant: You can omit the redstone dust entirely and place the daylight detector directly against the side of the comparator for an even smaller footprint.
  • Decorative Hiding: If you use the redstone dust layout, you can surround the wiring with half-slabs or elevate the dust on a slab so only the daylight detector pokes out flush with the ground.
  • Adjusting the Trigger Time: By adding or removing items in the hopper, you change the threshold signal strength. More items make the circuit turn on earlier in the evening; fewer items make it wait until deeper into the night.
  • Creative Eternal Day: Place a command block directly in front of the comparator with the command /time set 3000 to automatically reset the world to morning as soon as dusk hits.

Frequently asked questions

Why is my comparator outputting a signal during the middle of the day?
Make sure you have right-clicked the comparator so the front torch is lit (subtract mode), and ensure the daylight detector holds a clear view of the sky above it.
Why did the video choose a hopper instead of a chest?
A hopper only has 5 inventory slots compared to a chest's 27 slots, so you only need 2.5 stacks of items to half-fill it instead of 13.5 stacks.
Why doesn't the output signal reach my lamps?
When the sunset threshold is first crossed, the comparator only outputs a signal strength of 1. Place a redstone repeater directly in front of the comparator to boost the signal to 15.

Components used

More daylight / day-night timer