Description: This project aims to develop expertise in using seven-segment displays in various applications. The system will be designed to display any integer from 0 to 9999 using four seven-segment displays. A function named Print() will be created to facilitate the process of displaying integers on these segments. After testing the Print() function, it can be integrated into other projects seamlessly. This approach to code reuse simplifies the development of larger projects. The sample project will demonstrate the function by looping through and displaying all numbers from 0 to 9999.
The program is structured to showcase the use of seven-segment displays in multiplexed mode. It includes the necessary libraries and defines the ports for the displays. The main components of the program are as follows:
1. **SevenSegment Function**: This function takes a digit and a decimal point indicator as inputs. It writes the corresponding binary value to the display port based on the digit provided. If the digit exceeds 9, an error indication is displayed.
2. **Wait Function**: This function introduces a delay in the program, allowing time for the display to update.
3. **Print Function**: This function takes a 16-bit integer, breaks it down into its individual digits, and stores them in an array. If the number exceeds 9999, the function exits without processing.
4. **Main Function**: This is the core of the program, where the timer is configured and the displays are initialized. It enters an infinite loop that calls the Print() function to display numbers from 0 to 9999, with a delay between each update.
5. **Interrupt Service Routine (ISR)**: This routine is triggered by a timer overflow and is responsible for updating the displays. It cycles through the displays, activating one at a time and writing the corresponding digit to it.
The project utilizes AVR microcontroller programming, specifically leveraging the AVR I/O library for direct port manipulation. The seven-segment display is controlled through a multiplexing technique, which allows multiple displays to be controlled with fewer I/O pins. Each display is activated in succession, ensuring that only one display is illuminated at any given time, which creates the illusion of all displays being active simultaneously.
This project serves as an excellent introduction to working with seven-segment displays, providing foundational knowledge that can be applied to more complex electronic systems. The ability to reuse the Print() function in future projects enhances efficiency and reduces development time.A small project that will make you expert in using these displays in your own projects. We will make a system that can display any number between 0-9999 using four of these displays. We will design a function Print() that we can use on latter projects to easily write integers onto displays. Once we have successfully tested this function we can add to to any project without any problem. This concept of code reuse will make bigger project both easy to make and far less painful. In this sample project we will test our function by using it in a loop to print all numbers from 0-9999. /* Program to demonstrate the use of Seven Segment Displays In Multiplexed Mode. _ Author: Avinash Gupta Date: 11 Oct 08 Updated: Web: */ #include #include #include #define SEVEN_SEGMENT_PORT PORTD #define SEVEN_SEGMENT_DDR DDRD volatile uint8_t digits[3]; void SevenSegment(uint8_t n, uint8_t dp) { /* This function writes a digits given by n to the display the decimal point is displayed if dp=1 Note: n must be less than 9 */ if(n<10) { switch (n) { case 0: //.
gfedcba SEVEN_SEGMENT_PORT=0b00111111; break; case 1: //. gfedcba SEVEN_SEGMENT_PORT=0b00000110; break; case 2: //. gfedcba SEVEN_SEGMENT_PORT=0b01011011; break; case 3: //. gfedcba SEVEN_SEGMENT_PORT=0b01001111; break; case 4: //. gfedcba SEVEN_SEGMENT_PORT=0b01100110; break; case 5: //. gfedcba SEVEN_SEGMENT_PORT=0b01101101; break; case 6: //. gfedcba SEVEN_SEGMENT_PORT=0b01111101; break; case 7: //. gfedcba SEVEN_SEGMENT_PORT=0b00000111; break; case 8: //. gfedcba SEVEN_SEGMENT_PORT=0b01111111; break; case 9: //. gfedcba SEVEN_SEGMENT_PORT=0b01101111; break; } if(dp) { //if decimal point should be displayed //make 7th bit high SEVEN_SEGMENT_PORT|=0b10000000; } } else { //This symbol on display tells that n was greater than 9 //so display can`t handle it SEVEN_SEGMENT_PORT=0b11111101; } } void Wait() { uint8_t i; for(i=0;i<10;i+) { _delay_loop_2(0); } } void Print(uint16_t num) { /* This function breaks apart a given integer into separate digits and writes them to the display array i. e. digits[] */ uint8_t i=0; uint8_t j; if(num>9999) return; while(num) { digits[i]=num%10; i+; num=num/10; } for(j=i;j<4;j+) digits[j]=0; } void main() { uint16_t i; // Prescaler = FCPU/1024 TCCR0|=(1< i=0; } else { //Goto Next display i+; } //Activate a display according to i PORTB&=(0b11110000); PORTB|=(1<
This circuit employs an 87C57 microcontroller along with several peripherals to convert X-10 power-line carrier-code formats from a personal computer for use with an X-10 power-line interface in a home-control system. Software details can be found in the reference.
The circuit...
Efforts were made to minimize the number of wire jumpers on this board, but space constraints arose due to the integration of the microcontroller and motor driver on a single board. The design would have been cleaner without the inclusion...
This project is not to introduce Tic Tac Toe. Everyone knows this game. It is to introduce two features: bi-coloured LEDs, microcontrollers, and the skill of writing an ALGORITHM. You can use the project to learn the skills of creating...
This document presents an overview of the hardware design of the Handy Cricket.
The Handy Cricket is a compact electronic device designed for educational and recreational purposes, primarily aimed at children. The hardware design incorporates various components that work together to...
Utilize a high-performance microcontroller (Piccolo TMS320F28035, 12-bit resolution, +/- 4 LSB offset, +/- 60 LSB gain) to measure the voltage across stacked battery cells and control related analog electronics for charge equalization. The microcontroller will also save data in EEPROM...
The Skeyeball project is an ongoing initiative within the Indiana University System Design Methods Laboratory, aimed at providing graduate and undergraduate students with opportunities to engage in embedded system design and implement various projects. The downlink segment of the project...
Upon entering the password, the application, in this case "LED," will illuminate. In this digital locking system project, the interfacing of a keypad and a 16x2 LCD with a microcontroller will be explored, along with the accompanying code. This project...
Acquire all the components required for this lecture here. It is highly recommended to obtain a multimeter with a continuity setting. A quality multimeter with this feature typically costs around $60, while premium models can reach $300. The $60 option...
The driving circuit depicted in Figure 18-12 consists of a connection between the driving portion, the microcontroller, and the air conditioning operation components of the bridge. The microcontroller's digital signal levels from ports P4.0 to P4.3 (approximately 12 feet) and...
We use cookies to enhance your experience, analyze traffic, and (if you allow) serve personalized ads.
By clicking Accept All, you agree to our use of cookies.
Learn more