SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By Geert Gijsemans
#198470
Hello,

I'm a complete newbie and i'm building some stuff.
For a project i need a simple countdown timer. When you press a button i need to start a countdown from 3 to 0
I am using a spark fun large 7 segment display and a large digit driver connected to an arduino uno.
I know for a lot of you this is a far to easy project but, like i said before...i'm a complete newbie.

Can someone please help me with the code.

I already used the hook up guide on sparkfun learning but the code is way to difficult for me :?

Thanks

Geert
By paulvha
#198489
Replace the void setup() in the code from the hookup guide with the following
Code: Select all
 
void setup()
{
  Serial.begin(9600);
  Serial.println("Large Digit Driver Example");

  pinMode(segmentClock, OUTPUT);
  pinMode(segmentData, OUTPUT);
  pinMode(segmentLatch, OUTPUT);

  digitalWrite(segmentClock, LOW);
  digitalWrite(segmentData, LOW);
  digitalWrite(segmentLatch, LOW);

  while(1)
  {
      // in case some old input was pending remove it first
      while (Serial.available())    Serial.read();
      
      Serial.println();
      Serial.println("Press any key to start counting down");
      Serial.println();

      // now wait for Serial input to be available
      while (!Serial.available());

      // read that serial input and disgard
      while (Serial.available())  Serial.read();

      // countdown from 3 to 0
      for (int x = 3 ; x >= 0 ; x--)
      {
          //for debugging show on your screen
          Serial.println(x); 
          
          // post the number (false will NOT show the digital point)
          postNumber(x, false);

          // wait 1000 ms = 1 second. This can be adjusted to your needs
          delay (1000);
      }

      // clear the display, but set the digital point to show the display is on
      postNumber(' ', true);
  }
}