The schematic used in this project was based off of the same general schematic used for the previous two labs. Some extraneous portions of these previous schematics were removed, but the basic circuit connecting the board to the LCD with a potentiometer for dimming was left untouched. The notable addition made by our group was the common cathode RGB LED connected to PC0, PC1, and PC2, along with three current limiting resistors connecting the three leads to the board. This LED, though admittedly not used to its full potential, was used to indicate pauses in the operations of functions as well as the completion of the timer function.
The goal of this project was to create a Timer and Stop Watch that uses the UART display, LCD and a push button to interact with the user. The main idea was to understand how to set interrupts to create a 1 second delay to maintain the proper time. Using the Atmega328PB board that was used throughout the semester, and LCD and the built in push button on the Atmega board, the user will be able to select the function for Stopwatch/Timer on the UART, press the push button to begin timer/stopwatch and watch the time count up/down on the LCD. This requires understanding on the registers to set the interrupts and configuring the code to display time in the proper format to the LCD. Later, a RGB led is used to flash from red to rreen to inform the user time is up. The idea was to create a elaborate light display to do so, but because of time constraints, a single RGB led was utilized.
The code above is used to maintain and countdown time for the timer/stopwatch in this project. It is set in the interrupt and is calculated for every second. Due to the nature of the LCD, it is required to use and display the time using an array. Therefore, the ten’s place of the minute, one’s place of the minute, ten’s place of the seconds and one’s place of the seconds is used to calculate time along with the interrupts. For the purpose of this project, the maximum value of time is 59 minutes, therefore the if else statement above considers the value in the format of ##:## and counts up from the one’s place of the seconds and once that reaches 0, increments the ten’s place by one and then repeats this til stop watch is stopped.