counter with 7 segment LED serial display

I trying to write a program to count every time a button is pushed and display on a 4 digit-7 segment LED display. Through the serial monitor, the code registers the button push, but the LED display doesn't even light up. Honestly, I don't know how to test it. The display has 5 pins off the side. 5V for power and GND for ground are together and DIN, LOAD/CS, AND CLK grouped together. I am only connecting the DIN to the TX on the arduino pin. Do the other have to be connected as well and if so where?

#include <LiquidCrystal.h>

#include <SoftwareSerial.h>  //for software serial communication



#define txPin 1  //change to your serial port on Arduino board
#define rxPin 0  //not used but is required

SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
int buttonPressCount;


const int  buttonPin = 9;    //the pin that the pushbutton is attached to




int buttonPushCounter = 0;   //counter for the number of button presses
int buttonState = 0;         //current state of the button
int lastButtonState = 0;     //previous state of the button


void setup()  {
  pinMode(buttonPin, INPUT);  //initialize the button pin as a input
  Serial.begin(9600);  //initialize serial communication

  pinMode(txPin, OUTPUT);
  //the following resets the board, changes the brightness to 100%, and sets the board to '0000':
  mySerial.begin(9600);
  mySerial.write((byte)0x7A); //special character
  mySerial.write((byte)0x00); //set brightness to full
  mySerial.write((byte)0x76); //reset board
  mySerial.print(0); //send '0' character
  mySerial.print(0); //send '0' character
  mySerial.print(0); //send '0' character
  mySerial.print(0); //send '0' character
}

void loop(){

  buttonState = digitalRead(buttonPin);  //read the pushbutton input pin

    // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button
      // went from off to on:
      buttonPushCounter++;

      Serial.print("number of button pushes:  ");
      Serial.println(buttonPushCounter, DEC);
      updateDisplay(buttonPushCounter);  //function to update the display 'requires button press count'


    } 

  }

  lastButtonState = buttonState;  // save the current state as the last state, for next time through the loop



}




void updateDisplay(int buttonPushCounter){
  String intString = String(buttonPushCounter);  //changes integer to a string
  char displayChars[4];  //create array to hold the four numbers
  int stringLength = intString.length();  //get length of the string
  //the following will determine if the button press count variable has 1, 2, 3, or 4 numbers in it
  //and will fill the empty spaces with '0'. so if the button press count variable is '29' it will end up being '0029':
  if(stringLength == 4){
    displayChars[0] = intString.charAt(0);
    displayChars[1] = intString.charAt(1);
    displayChars[2] = intString.charAt(2);
    displayChars[3] = intString.charAt(3);
  }
  else if(stringLength == 3){
    displayChars[0] = 0;
    displayChars[1] = intString.charAt(0);
    displayChars[2] = intString.charAt(1);
    displayChars[3] = intString.charAt(2);
  }
  else if(stringLength == 2){
    displayChars[0] = 0;
    displayChars[1] = 0;
    displayChars[2] = intString.charAt(0);
    displayChars[3] = intString.charAt(1);
  }
  else if(stringLength == 1){
    displayChars[0] = 0;
    displayChars[1] = 0;
    displayChars[2] = 0;
    displayChars[3] = intString.charAt(0);
  }
  mySerial.write((byte)0x76); //Reset board
  mySerial.write((byte)0x76); //Reset board
  mySerial.print(displayChars[0]); //Send '0' character
  mySerial.print(displayChars[1]); //Send '0' character
  mySerial.print(displayChars[2]); //Send '0' character
  mySerial.print(displayChars[3]); //Send '0' character

  delay(100); //this will make it so you don't get double counts. you could also use this to avoid someone pressing the button repeatedly 'for fun!'

}

4 digit-7 segment LED display

Give us a link to this item.

#include <LiquidCrystal.h>

Why are you using this?

I am so new to this it is not even funny. My student wanted to make a valentine counter so everytime a box was opened it would tell her that she got a new valentine (5 grade projects). I searched on line and found this Arduino Button Press Counter Display SERIAL LED - YouTube I repurposed the code as shown but for some reason the display will not go on. It gives me a little flicker when it is connected, but that's it.

http://www.amazon.com/gp/product/B00A8H6BQ2/ref=oh_details_o02_s00_i00

gizahuna:
I am only connecting the DIN to the TX on the arduino pin. Do the other have to be connected as well and if so where?

Yes, of course they do. It looks as if your display may use some sort of Wire interface. You need to identify the display and work out how to drive it.

Oh, and setting up a SoftwareSerial port on the hardware serial pins does not seem to be a very useful thing to do.

https://www.youtube.com/watch?v=wfHCKhXEM6Y

This link has the ZIP file containing the: sketch: Readme: PNG & parts list he is using.
He is using TTL serial communications.

Your display has sample code in the 4th image at: http://www.amazon.com/gp/product/B00A8H6BQ2/ref=oh_details_o02_s00_i00

I believe your Data Sheet for the display is here and it is SPI communications.

Great...I have the sample code that came with the board, but I'm still a little confused on how to hook it up to the uno board (IE: CS/LOAD, CLK, AND DIN) should go where on the board.