Getting Started with Arduino! – Chapter Five


Welcome back fellow arduidans!



Recall from our exercise 4.1, this part of the sketch:




and a video:




a = 10 % 3;














and the video:


Exercise 5.1


You will need:

  • Two 7-segment, common-cathode displays
  • Two 74HC595 shift registers
  • a breadboard and some connecting wire
  • some water



and the ubiquitous video:

And here is the sketch for my interpretation of the answer.

Exercise 5.2


  • Basically a “Binary quiz” machine of some sort!


You will need: (to recreate my example below)

  • Three 7-segment, common-cathode displays
  • eight LEDs (for binary number display)
  • Four 74HC595 shift registers
  • a breadboard and some connecting wire
  • 10k linear potentiometer (variable resistor)
  • some water

For inspiration here is a photo of my layout:






The following two tabs change content below.

John Boxall

Person. Author of Director of Rare updater of VK3FJBX

17 Responses to “Getting Started with Arduino! – Chapter Five”

  1. Mr Guy says:

    i have a question about the 74HC595. How can you read inputs plugged in it? i want to plug a matrix 4×4 keypad…
    thank you for your answer…..

  2. Russ says:

    John, Thanks for the helpful tutorial. On the car sketch, you have void go–(int runtime) but runtime is never given a value. Is this a misprint, or how does this work?

    Thanks, Russ

    • John Boxall says:

      The value for runtime is entered when using the function. See void loop(). When we use (for example)
      runtime is given a value of 1000. Etc.

  3. ed says:

    Interesting. Just a question though. As the result of filling out the 7 segment table will always be:
    {63,6,91,79,102,109,125,7,127,111 } for the base-10 values,am i correct to presume that the actual decision on what segment lights up is made by selecting which segment pin is connected to which 595 pin?
    But can I presume that regardless of the pin-out of the 7 segment display, it will always be:
    595 pin Q0 -> a
    595 pin Q1-> b
    595 pin Q6->g
    595 pin Q7-> DP ?

    Also, when using 2 x 595 for 2 x 7segment displays, do I understand correctly that the 2nd display will be fed from the 2nd 595 and not partly from the remaining pins on the first 595?

    And lastly, it seems to me that the base-10 values from the table are solely for common cathode displays and that for common anode displays, the value shld be the binary inverse after all, they are hanging from the + line and have the segment -via a resister- coupled to the 595. That particular pin shld be low to light up the segment, whereas it wld need to be high to light up a common cathode segment
    Am I correct?

    • John Boxall says:

      You need to confirm the pinouts of your 7-segment display, however in my tutorials – yes Q0>display ‘a’, etc. Yes, one display per 74HC595 (there aren’t any spare pins).
      Haven’t tried it with common-anode, but yes binary inverse etc.

      • ed says:

        Thanks John, tried it, worked pretty OK, but I was a bit disappointed by the output of the example sketch. Seemed that the 7segment first started to count the odd numbers and then the even numbers and it was really flickering a lot, not really the bright clear numbers as in yr video
        Looking at the code it just shld have displayed all the numbers first going up and then down.
        Maybe it is a timing issue with the 595. What I did notice is that changing the delays in yr code had quite an influence on any numbers being shown at all.
        As I have learned first to seek the faults at my end first. I have checked all the connections (good) and checked putting direct current (direct as in ‘without any arduino or 595’, just with a battery and resistors) and the the numbers were perfectly clear. I changed the code to just show my one number and that was fine for each number, but sequencing it (counting up and down) just did not go well..

        Hmm. Too bad. I am probably overlooking something.

        Nevertheless, I wld never have come this far without yr excellent tutorial

  4. ed says:

    Thanks for yr sugegstion John. I suspect that a faulty wire hooking up the RST to pin 10 might have been the reason. After replacing that wire it went like .. eh.. clockwork

  5. Garry says:

    Exercise 5.1
    I have a small breadboard so I could not fit eight resistors on it
    so I used two resistors from pins 3 -8 as per your display to ground
    this seems easier than eight resistors and works well
    will this be ok

    • John Boxall says:

      There is a theoretical risk of too much current, if you were building a permanent version then use all the resistors. But for short term experimenting you’ll be fine.

  6. mohannad rawashdeh says:

    interesting tutorial ,thank you for it .

    u ‘re used Common cathode seven seg,,unfortunately i didn’t have one ,but I reprogramming arduino on Common anode 7 seg, using your idea “truth table” I successed on it , just i change the following code

    int segdisp[10] = {192,249,164,176,153,146,130,248,128,144 };

    all thing worked well

    thank you again

  7. archie rowley says:

    if the numbers you send are integers with shiftout then they are 16 bits. why does it send 8 bits. could the array be declared byte that stores the code to send to the 7 segment displays.

    • John Boxall says:

      From memory shiftOut() only sends 8 bits. You could certainly use byte as you mentioned.

      • archie says:

        many thanks. having worked through some of your tutorials i realised that the best way to find out something is to try it, which i did. more enjoyable than just asking questions


Leave a Reply to mohannad rawashdeh

Subscribe via email

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: