#include <Wire.h> #define latchPin 11 // SR Latch Pin 12 Digital pin #define clockPin 9 // SR Clock Pin 11 Digital pin #define dataPin 12 // SR Pin 14 PWM pin int ones = 0; int ones_hex = 0; int tens = 0; int tens_hex = 0; int hundreds = 0; int hundreds_hex = 0; int thousands = 0; int thousands_hex = 0; int total = 0; int LCD_Position[10]={ 0xfc, 0x60, 0xda, 0xf2, 0x66, 0xb6, 0xbe, 0xe0, 0xfe, 0xe6 }; void split(int input_number){ // splits and writes the 4 didgit number to the // ones, tens, hundreds, and thousands variables Serial.print("Input Number "); Serial.println(input_number); thousands = int(input_number/1000); Serial.print("Thousands "); Serial.println(thousands); hundreds = int(input_number/100); hundreds = hundreds-(int(hundreds/10)*10); Serial.print("Hundreds #2 "); Serial.println(hundreds); tens = int(input_number/10); tens = tens-(int(tens/10)*10); Serial.print("Tens #2 "); Serial.println(tens); ones = input_number-(int(input_number/10)*10); Serial.print("Ones "); Serial.print(ones); Serial.println(" "); } void zero_out(){ //start by blanking the LEDS digitalWrite(latchPin, LOW); //Shifts data to highbyte second digit //You change the d1 to d4 to low to activate shiftOut(dataPin, clockPin, LSBFIRST, 0x00); //Shifts data to lowbyte, number 7 with decimal point shiftOut(dataPin, clockPin, LSBFIRST, 0x00); digitalWrite(latchPin, HIGH); delay(2000); } void setup() { Serial.begin(9600); pinMode (latchPin,OUTPUT); pinMode (dataPin,OUTPUT); pinMode (clockPin,OUTPUT); } void loop() { //Shifts data to highbyte second digit //You change the d1 to d4 to low to activate //ABCD0000 //A is first LED Left most or thousands //B is second LED Left Middle or hundreds //C is third LED Right Middle or tens //D is fourth LED Right most or ones zero_out(); for(int count = 0; count<10; count++){ //A is first LED Left most or thousands will be 7 //0111 0000 is thousands digitalWrite(latchPin, LOW); //Shifts data to highbyte second digit //You change the d1 to d4 to low to activate shiftOut(dataPin, clockPin, LSBFIRST, 0x70); //Shifts data to lowbyte, number 7 with decimal point shiftOut(dataPin, clockPin, LSBFIRST, LCD_Position[count]); digitalWrite(latchPin, HIGH); delay(250); } for(int count = 0; count<10; count++){ //B is second LED Left Middle or hundreds //1011 0000 is hundreds digitalWrite(latchPin, LOW); //Shifts data to highbyte second digit //You change the d1 to d4 to low to activate shiftOut(dataPin, clockPin, LSBFIRST, 0xb0); //Shifts data to lowbyte, number 7 with decimal point shiftOut(dataPin, clockPin, LSBFIRST, LCD_Position[count]); digitalWrite(latchPin, HIGH); delay(250); } for(int count = 0; count<10; count++){ //C is third LED Right Middle or tens //1101 0000 is tens digitalWrite(latchPin, LOW); //Shifts data to highbyte second digit //You change the d1 to d4 to low to activate shiftOut(dataPin, clockPin, LSBFIRST, 0xd0); //Shifts data to lowbyte, number 7 with decimal point shiftOut(dataPin, clockPin, LSBFIRST, LCD_Position[count]); digitalWrite(latchPin, HIGH); delay(250); } for(int count = 0; count<10; count++){ //D is fourth LED Right most or ones //1110 0000 is ones digitalWrite(latchPin, LOW); //Shifts data to highbyte second digit //You change the d1 to d4 to low to activate shiftOut(dataPin, clockPin, LSBFIRST, 0xe0); //Shifts data to lowbyte, number 7 with decimal point shiftOut(dataPin, clockPin, LSBFIRST, LCD_Position[count]); digitalWrite(latchPin, HIGH); delay(250); } // write A and B to 7 //0011 0000 is A and B with 7 digitalWrite(latchPin, LOW); //Shifts data to highbyte second digit //You change the d1 to d4 to low to activate shiftOut(dataPin, clockPin, LSBFIRST, 0x30); //Shifts data to lowbyte, number 7 with decimal point shiftOut(dataPin, clockPin, LSBFIRST, 0xe0); digitalWrite(latchPin, HIGH); delay(250); zero_out(); // write A and C to 7 //0101 0000 is A and C with 7 //1110 0000 is 7 digitalWrite(latchPin, LOW); //Shifts data to highbyte second digit //You change the d1 to d4 to low to activate shiftOut(dataPin, clockPin, LSBFIRST, 0x50); //Shifts data to lowbyte, number 7 with decimal point shiftOut(dataPin, clockPin, LSBFIRST, 0xe0); digitalWrite(latchPin, HIGH); delay(250); zero_out(); // write A and D to 7 //0110 0000 is A and D with 7 //1110 0000 is 7 digitalWrite(latchPin, LOW); //Shifts data to highbyte second digit //You change the d1 to d4 to low to activate shiftOut(dataPin, clockPin, LSBFIRST, 0x60); //Shifts data to lowbyte, number 7 with decimal point shiftOut(dataPin, clockPin, LSBFIRST, 0xe0); digitalWrite(latchPin, HIGH); delay(250); }