Large Digital Driver

Hello,

I require some help, I have successfully used the code for the timer tutorial for the large digit driver and even implemented a keypad function to it, I disable the timer and now can input numbers I enter via a keypad.

the only issue I have is that I wish to clear the LED so a new number can be inputted without the previous numbers, I have tried loops and counters, added digital write and set it to low before the start of a new loop, I have gotten mixed results.

just need someone to point me in the right direction concerning the clearing of the old numbers? I am sure the solution is simple, but can’t get my head around it.

Thank you.

#include <Key.h>
#include <Keypad.h>
#include <stdlib.h>
#include <stdio.h>

    /*
 Controlling large 7-segment displays
 By: Nathan Seidle
 SparkFun Electronics
 Date: February 25th, 2015
 License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

 This code demonstrates how to post two numbers to a 2-digit display usings two large digit driver boards.

 Here's how to hook up the Arduino pins to the Large Digit Driver IN

 Arduino pin 6 -> CLK (Green on the 6-pin cable)
 5 -> LAT (Blue)
 7 -> SER on the IN side (Yellow)
 5V -> 5V (Orange)
 Power Arduino with 12V and connect to Vin -> 12V (Red)
 GND -> GND (Black)

 There are two connectors on the Large Digit Driver. 'IN' is the input side that should be connected to
 your microcontroller (the Arduino). 'OUT' is the output side that should be connected to the 'IN' of addtional
 digits.

 Each display will use about 150mA with all segments and decimal point on.

*/
const byte numRows= 4; //number of rows on the keypad
const byte numCols= 3; //number of columns on the keypad

char keymap[numRows][numCols]= 
{
{'1', '2', '3'}, 
{'4', '5', '6'}, 
{'7', '8', '9'},
{'*', '0', '#'}
};

//Code that shows the the keypad connections to the arduino terminals
byte rowPins[numRows] = {7,6,5,4}; //Rows 0 to 3
byte colPins[numCols]= {3,2,9}; //Columns 0 to 3

Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
//GPIO declarations
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
byte statLED = 13; //On board status LED
byte segmentClock = 11;
byte segmentLatch = 10;
byte segmentData = 12;

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

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);
   
}
 
int a = 0;


void loop()
{
  char keypressed = myKeypad.getKey();
  a = keypressed;

	if (keypressed != NO_KEY )
	{
  		 showPvalue (a);
	}

  
delay (50);
}
//Takes a number and displays 2 numbers. Displays absolute value (no negatives)
void showPvalue(float value)
{
  int number = abs(value); //Remove negative signs and any decimals
  
  int b = value - '0' ; //converts ascii to int
  
  //Serial.print("number: ");
 // Serial.println(number);


  for (byte x = 0 ; x < 2 ; x--)
  {
    int remainder = b % 10;

    postNumber(remainder, false);

  b /= 10;
  
  
  }

  //Latch the current segment data
  digitalWrite(segmentLatch, LOW);
  digitalWrite(segmentLatch, HIGH); //Register moves storage register on the rising edge of RCK
}

//Given a number, or '-', shifts it out to the display
void postNumber(byte number, boolean decimal)
{
  //    -  A
  //   / / F/B
  //    -  G
  //   / / E/C
  //    -. D/DP

#define a  1<<0
#define b  1<<6
#define c  1<<5
#define d  1<<4
#define e  1<<3
#define f  1<<1
#define g  1<<2
#define dp 1<<7

  byte segments;

  switch (number)
  {
    case 1: segments = b | c; break;
    case 2: segments = a | b | d | e | g; break;
    case 3: segments = a | b | c | d | g; break;
    case 4: segments = f | g | b | c; break;
    case 5: segments = a | f | g | c | d; break;
    case 6: segments = a | f | g | e | c | d; break;
    case 7: segments = a | b | c; break;
    case 8: segments = a | b | c | d | e | f | g; break;
    case 9: segments = a | b | c | d | f | g; break;
    case 0: segments = a | b | c | d | e | f; break;
    case ' ': segments = 0; break;
    case 'c': segments = g | e | d; break;
    case '-': segments = g; break;
    case '*': segments = b | c | e | f | g; break;
  }

  if (decimal) segments |= dp;

  //Clock these bits out to the drivers
 
  for (byte x = 0 ; x < 8 ; x++)
 {
 
    digitalWrite(segmentClock, LOW);
    digitalWrite(segmentData, segments & 1 << (7 - x));
    digitalWrite(segmentClock, HIGH); //Data transfers to the register on the rising edge of SRCK
    
    //Serial.println(x);
 }
 
}

Would Watchdog help with this?

Try calling postNumber with (int)’ ’ - that should blank the display

/mike

Thank you for the information, ill do a little digging, would this be correct → postNumber (0,false);

n1ist:
Try calling postNumber with (int)’ ’ - that should blank the display

/mike

That almost worked, postNumber ( ’ ', false), I am using 3 LED, it works on two digit mode but not 3, thank you, I’ll try and play around to see if I can get it to do what I want.

The postNumber function only shifts out one digit at a time. If you have multiple digits, you’ll have to call it multiple times.

solved, got it working thank you all for all the help, took a bit, but using arrays and switches, I have made it work. cheers.