Sunday, November 29, 2020

Semester Countdown

This Week's Overview

Week 5 in some ways has been more stressful than even the first week of class.  Trying to juggle Thanksgiving, my children coming in from the Houston area, and the week 5 assignments has been challenging.  My 1 year old granddaughter hid my mouse, and my 9 year old granddaughter had to help me with my circuit.  Luckily my 4 year old grandson was happy to watch TV & play with the goats.

I was excited that we were able to pick our own Tech Play circuit for the assignment.  Since I am counting the days to the semester's end, I chose to build a circuit with a 7 segment display.

7 Segment Display

This particular circuit requires more than just placing the display on the board & uploading the code.  In addition to the 7 segment display there is a 74HC595 shift register integrated circuit (IC), 8-220 ohm resistors, & approximately 26 jumper wires.  Learning the pin out for the IC and the display was a bit confusing.  When I first looked at the diagram for the circuit all the pins on the display were depicted to be on the left side.  In actuality, the 10 pins on the display are at the top & bottom of the component.  Pins 3 & 8, which are the center pins on each end, are the ground pins.  I had to look on the internet to refresh my memory on how to read the pin positions on the 74HC595 shift register IC.  Using components that have fixed pin positions made the assembly process much harder than using LEDs which can be spread out on the breadboard.

IC to Display Pin Configuration

7 Segment Display Pin Designation

Looking at the chart helped me understand which pin on the IC should connect to the corresponding pins on the display.  I am glad that the CD which came with my starter kit has such good information.  The CD contained step by step instructions, but they seemed confusing to me, so I opted to use the schematic to make my wiring connections.

Schematic

Picture Wiring Diagram

It was difficult to wire up the circuit even with the color coded schematic.  The pins on the IC & the Display are so close together that it was extremely difficult to connect the jumper wires on the breadboard to the corresponding pins.  It took me several attempts to get the wires in the correct position.  The first time I tested the circuit the G designation on the display did not light up.  I had to retrace all the jumper wires and ultimately swap two of them.  Once I did that I was able to run the program successfully.  Immediately below is the code that was furnished with the kit, with some timing modifications.  The original code had the delay set at 1000, but I thought the numbers changed too fast so I changed the delay to 2500.

7 Segment Display Code

//www.elegoo.com
//2016.12.12

// define the LED digit patterns, from 0 - 9
// 1 = LED on, 0 = LED off, in this order:
//                74HC595 pin     Q0,Q1,Q2,Q3,Q4,Q5,Q6,Q7 
//                Mapping to      a,b,c,d,e,f,g of Seven-Segment LED
byte seven_seg_digits[10] = { B11111100,  // = 0
                              B01100000,  // = 1
                              B11011010,  // = 2
                              B11110010,  // = 3
                              B01100110,  // = 4
                              B10110110,  // = 5
                              B10111110,  // = 6
                              B11100000,  // = 7
                              B11111110,  // = 8
                              B11100110   // = 9
                             };
 
// connect to the ST_CP of 74HC595 (pin 3,latch pin)
int latchPin = 3;
// connect to the SH_CP of 74HC595 (pin 4, clock pin)
int clockPin = 4;
// connect to the DS of 74HC595 (pin 2)
int dataPin = 2;
 
void setup() {
  // Set latchPin, clockPin, dataPin as output
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}
 
// display a number on the digital segment display
void sevenSegWrite(byte digit) {
  // set the latchPin to low potential, before sending data
  digitalWrite(latchPin, LOW);
     
  // the original data (bit pattern)
  shiftOut(dataPin, clockPin, LSBFIRST, seven_seg_digits[digit]);  
 
  // set the latchPin to high potential, after sending data
  digitalWrite(latchPin, HIGH);
}
 
void loop() {       
  // count from 9 to 0
  for (byte digit = 10; digit > 0; --digit) {
    delay(2500);
    sevenSegWrite(digit - 1); 
  }
   
  // suspend 4 seconds
  delay(2500);
}

Pictures/Videos of the circuit

Top View

Side View

Arduino Side View

Video 1: Slower Speed

Video 2: Faster Speed

Reflections

This project was much more difficult than I thought it would be when I picked it.  I initially placed a couple of wires in the wrong place and had to trace all the connections to find the mistake.  That took considerable time.  This project is most like the score boards and the countdown timers used at sporting events, although they have more than one display (typically 3).  It could also work in a kitchen timer. I feel very satisfied that I was able to get the project to function, even though I had to use the furnished code. I am glad I was able to modify the timing on the code.

No comments:

Post a Comment

The Last Hurrah

  Final Vanity Search FireFox Search In addition to the original information I found in our first vanity search, I found this informatio...