First Place a Redstone Comparator on the ground and right click it once.
Then, place 3 redstone around it left, top left corner, and top
Then, place 3 more redstone going away from the comparator starting at the top redstone
Then, place command block, comparator, command block, repeater, command block
Then Put These Commands In The 3 Command Blocks