<p>What we have is two pistons, one in front of the other. Let's call them the front and back pistons.</p>
<p>When powered, it pushes a node forward by two blocks. When unpowered, it pulls a node backward by two blocks.</p>
<p>This is a pretty simple circuit, but there are a lot nuances to be aware of with regards to timing and ordering. For example, an extended piston cannot be pushed or pulled correctly since the stopper is out, and a sticky piston pulls when it receives an off signal, but not when it is dug.</p>
<h4>Step 1: Design</h4>
<p>The first step in building something is knowing what you want to do. Let's see what we're looking for when doing pushing:</p>
<ol>
<li>The back piston is powered, pushing the front piston and node forward one block.</li>
<li>The front piston is powered, pushing the node forward one block.</li>
</ol>
<p>Pretty simple for now. How about retracting?</p>
<ol>
<li>The front piston is unpowered, pulling the node back one block.</li>
<li>The back piston is unpowered, pulling the front piston back one block.</li>
<li>The front piston is powered, touching the node.</li>
<li>The front piston is unpowered, pulling the node back one block.</li>
</ol>
<p>The retraction is a bit more complex since sticky pistons can only pull one block at a time.</p>
<h4>Step 2: Layout</h4>
<p>First, we need to set up the basic components. In other words, the pistons and the node we are pushing/pulling:</p>
<p>On the left we have the rear piston, on the middle, the front piston. To the right we find the node itself. I used cobble as an example.</p>
<h4>Step 3: Control</h4>
<p>Now that the pistons are in place, there needs to be some way of converting the on/off signal into the sequences described in Step 1. There are a whole bunch of ways you can go about this, but I find that the easiest way is to simply use a Luacontroller and wire three of the four ports into their proper places:</p>
<p>You'll notice that I connected the fourth, unused port to a switch. This will be our signal. When turned on, the circuit will perform the extension sequence. When turned off, the circuit will perform the retraction sequence.</p>
<p>At the moment the circuit can be made significantly smaller, but we will cover that later.</p>
<h4>Step 4: Programming</h4>
<p>If you don't know much about Luacontrollers, you might find the <ahref="http://mesecons.net/luacontroller/">Luacontroller tutorial</a> handy.</p>
<p>We're going to first outline the basic actions the controller will perform:</p>
<predata-language="lua">if pin.a then
--extend
else
--retract
end</pre>
<p>Then, work forwards through each sequence. I obtained the following as the final result:</p>
<predata-language="lua">if event.iid == "pull1" then
port.b = false
interrupt(0.2, "push2")
elseif event.iid == "push2" then
port.c = true
interrupt(0.2, "pull2")
elseif event.iid == "pull2" then
port.c = false
else
if pin.a then --extend
port.b = true
port.d = true
else --retract
port.d = false
interrupt(0.2, "pull1")
end
end</pre>
<p>Congratulations! You now have a working double piston extender.</p>
<h4>Step 5: Improvements</h4>
<p>We're not done yet though. The circuit can still be made better. For example, we can remove the row of wires leading up to the pistons:</p>
<p>All files are available under the same license as this article. The WEM schematics can be loaded using the //metaload command in <ahref="https://github.com/Uberi/MineTest-WorldEdit">WorldEdit</a>.</p>
<p><ahref="DoublePiston.wem"class="post">Double sticky piston driver in WorldEdit-Meta format (WEM)</a></p>
<p><ahref="DoublePiston.wem"class="post">Low profile double sticky piston driver in WorldEdit-Meta format (WEM)</a></p>
<br><br><br><br>
<arel="license"href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><imgalt="Creative Commons License"style="border-width:0"src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png"/></a><br/>This work is licensed under a <arel="license"href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.