Robo Garden Manual Testing Circuit Development

Now that I have the carriage moving a number of centimeters based on serial input, I want to add a testing circuit that will let me cycle to a specific position on the garden, or rather a "specific plant".

I want the following behavior:

  • Start the carriage from a home position "0"
  • Press a button to cycle through available positions (1-8)
  • After a time, the carriage will move to that position
  • I should be able to see the chosen position on a segment display
  • Pressing the button while the carriage is moving should have no effect
  • If I want to get fancy, the display will show a "spinny" motion during the move

Circuit Considerations

The most simple way to wire up a seven segment display is just to hook it up to ground and 7 digital pins of the Arduino. The disadvantage of this is, of course, that it consumes 7 digital pins. I already have 4 for the stepper, so 7 is a lot to devote to just a display, especially given the other inputs I'll need.

A better way is to use a chip like the the CD4511 Latch Decoder to drive the display; this chip takes 4 control pins to power as you are passing a binary number which the chip translates into the signals for the display:

  • 1100 Would show up as 3 (1+2+0+0)
  • 0010 Would show up as 4 (0+0+4+0)
  • 1001 Would show up as 9 (1+0+0+8)

And so forth.

This is great, I get 3 pins back.

But I think we can do better than that. Enter the shift register, 74HC595. With a shift register, you only need to use 3 pins of the Arduino to "shift" bits into the register. The result is you can get 8 bits of state out of the register. So, I can use 4 of them to control the LED driver chip and the other 4 for whatever I want. This could be another display chip, or simply high/low pin outs for other devices like relays.

Building the Circuit

Ok, so we will need:

The basic operation, is to connect 4 of the output bits of the shift register to the 4 input bits of the decoder, and the output pins of the decoder to the inputs of the display.

Circuit diagram with decoder and shift register

Hooking up the 7 Segment

Starting with the 7 Segment display, we need to determine the proper current limiting resistors. The voltage supplied will be 5 and the typical forward voltage listed on the data sheet is 2 volts. The forward current is rated at 15 mA so some quick Ohm's law:

  • R = V / I
  • R = (5v - 2v) / 0.015A
  • R = 200 Ohms (Red Black Brown)

I'll use the 220 Ohm resistors that I have available. For initial tests I put in a dip switch array to pick the bits adding 10k Ohm resistors to pull down to ground on the 4 bit inputs, as shown in this schematic:

Correct decoder wiring

Here is the resulting, albeit messy, initial prototype:

7 Segment display on breadboard

Adding the Shift Register

The next step will be to add the shift register in place of the dip switches. I found that this article was quite helpful in learning about the shift register chip, as well as the above data sheet. The wiring was simple and only three pins of the Arduino were used for the connection.

Full prototype breadboards and circuits


I started with this simple code, which causes the display to count up to 9 in order:

int sr_serial = 4;
int sr_clock = 5;
int sr_register = 6;

for (int j = 0; j < 10; j++) {
  digitalWrite(sr_register, LOW);
  shiftOut(sr_serial, sr_clock, MSBFIRST, j);
  digitalWrite(sr_register, HIGH);

Adding a Cycling Button

Now that I could display the value I wanted, I needed to add a button that will cycle up through the positions, and after the button is no longer being pressed, adjust the carriage to that location.

Cycle button circuit diagram

For this, we just have a button pulled low and read by the Arduino. I added a delays and logic in the code such that a timer is reset each time the button is pressed, if the timer has run out, and the location number is different than the previous number we fire a move command. What is nice about the stepper movement routine is that it is locking, so pressing the button during the carriage movement doesn't do anything. This will also come in handy so I don't spray water by accident when moving between plants.

Good Progress

Pretty soon though, I won't need to worry about manual manipulation as moisture sensors and a stop micro switch will provide feedback to the system.

Here is a picture of the completed circuit, much more cleaned up, replacing the jumpers with small wires:

Improved breadboard with cleaned up wires

If you enjoyed reading this or learned something, please consider sharing via , , or . Thanks!

If you enjoyed this article, you might like others related to the Robotics interest. This article is part of the Robogarden project.