CHIP LEDSTRIPS{ // Our output has 6 bits. // To adress the right-most output bit, we write out[0]. // The left-most output bit is out[5]. OUT out[6]; PARTS: // Each time we call the Program Counter, we increment its state by 1. // We only reset it if all LED lights are currently activated. PC(in = false , load = false , inc = true, reset = out[5], out = pcout); // Negated versions of the last three output bits of the PC. Not(in = pcout[0], out = not0); Not(in = pcout[1], out = not1); Not(in = pcout[2], out = not2); // We check the PC's state. If it's just been reset, it is now in state zero. // To save one line of code, we write "out[5]" instead of "six", because the last LEDs are only on in state "six". And3Way(in0 = not0, in1 = not1, in2 = not2, out = zero); And3Way(in0 = pcout[0], in1 = not1, in2 = not2, out = one); And3Way(in0 = not0, in1 = pcout[1], in2 = not2, out = two); And3Way(in0 = pcout[0], in1 = pcout[1], in2 = not2, out = three); And3Way(in0 = not0, in1 = not1, in2 = pcout[2], out = four); And3Way(in0 = pcout[0], in1 = not1, in2 = pcout[2], out = five); And3Way(in0 = not0, in1 = pcout[1], in2 = pcout[2], out = out[5]); // Create the six bit output by checking which LEDs should be on depending on the state we are in. // For example, the first LED strip is always on unless we are in state zero. // The third LED strip is on if we are in either state three, four, five or six (here called out[5]). Not(in = zero, out = out[0]); Or5Way(in0 = two, in1 = three, in2 = four, in3 = five, in4 = out[5], out = out[1]); Or4Way(in0 = three, in1 = four, in2 = five, in3 = out[5], out = out[2]); Or3Way(in0 = four, in1 = five, in2 = out[5], out = out[3]); Or(a = five, b = out[5], out = out[4]); }