A comment on a video about my desk recently asked,
I’d like to know how you wired up everything (the pi to the relayboard) using 2 GPIO pins. Could you please take a picture and upload it to your blog?
Good question, Jake. Here’s a picture.
But that’s not too clear, let’s break it down.
- This gray band connects the RPi to the breadboard to make it easy to make multiple connections. But you can connect directly from the pins to the breadboard; just make sure you bring power and ground as well. And you’ll beed male/female connecting wires to make the connection.
- Connect the 5v power (red wire above) and ground (black wire above) to the power/gnd pins on the relay.
- The breadboard lets us connect multiple wires to a single pin. When that pin is ‘on’ all three connected wires are signaled. In the picture above, the 3 green wires on one pin; the 3 blue wires are connected to a second pin.
- The green and blue wires are connected to the relays in alternating pairs. Each one turns on one relay when signaled, so each time the pin on the RPi is on it triggers 3 relays in my case (one for each actuator in my desk).
- For each of my actuators I use two relays. This allows the signal to be reversed by flipping which switch is on, thereby telling the actuator to extend or contract.
So, after all this, the code to extend, retract, and stop is easy!