Personal Blog – Dushyant

My First Arduino Circuit

by on Oct.14, 2013, under Electronics

After the workshop, I plugged in my Indiuno with the LCD and within half an hour had the LCD working.



Next up was using the 7-segment display and the shift register. After a lot of googling and experimenting – finally managed to set it up so that it counts from 0 to 9. I used the on-board switch on pin # 7. Had to use a lot of binary to decimal conversions to get the numbers correct – but finally got it down pat 🙂

Attached circuit diagram and sketch if anyone’s interested.


//Pin connected to ST_CP of 74HC595
int latchPin = 4;
//Pin connected to SH_CP of 74HC595
int clockPin = 3;
////Pin connected to DS of 74HC595
int dataPin = 2;
int buttonPin = 7;
int numberToDisplay = 0;
int segNumbers[10] = {126,48,109,121,51,91,95,112,127,123};

void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

void loop() {
      // take the latchPin low so 
      // the LEDs don't change while you're sending in bits:
      digitalWrite(latchPin, LOW);
      // shift out the bits:
      shiftOut(dataPin, clockPin, LSBFIRST, segNumbers[numberToDisplay]);  
      //take the latch pin high so the LEDs will light up:
      digitalWrite(latchPin, HIGH);
      if (digitalRead(buttonPin) == LOW){
        if (numberToDisplay > 9) {numberToDisplay = 0;}

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!


A few highly recommended websites...