{"id":1983,"date":"2018-07-04T23:48:27","date_gmt":"2018-07-04T23:48:27","guid":{"rendered":"https:\/\/deepbluembedded.com\/?p=1983"},"modified":"2023-08-17T23:53:28","modified_gmt":"2023-08-17T20:53:28","slug":"interfacing-7-segments-display-with-pic-microcontrollers","status":"publish","type":"post","link":"https:\/\/deepbluembedded.com\/interfacing-7-segments-display-with-pic-microcontrollers\/","title":{"rendered":"Interfacing 7-Segments Display With PIC Microcontrollers"},"content":{"rendered":"\n\n\n\n\n
\"Previous<\/a><\/td>\nPrevious Tutorial<\/strong><\/a><\/td>\nTutorial 5<\/span><\/strong><\/span><\/td>\nNext Tutorial<\/strong><\/a><\/td>\n\"Next<\/a><\/td>\n<\/tr>\n
<\/td>\nInterfacing 7-Segments With PIC MCUs<\/strong><\/span><\/td>\n<\/td>\n<\/tr>\n
<\/td>\nPIC Microcontrollers Course Home Page <\/strong><\/span>????<\/a><\/td>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

In this tutorial, you’ll learn how do 7-segments displays work, and how to interface 7-segments displays with PIC16F877a, PIC18F4550 microcontrollers in MPLAB IDE with XC8 compiler. So let’s get started!<\/span><\/p>\n

[toc]<\/p>\n


\n

\u00a0 \u00a0Components Needed for this tutorial\u00a0 \u00a0<\/span><\/strong><\/span><\/h3>\n\n\n\n\n\n\n\n\n\n\n\n
Quantity<\/span><\/strong><\/span><\/td>\nComponent Name<\/span><\/strong><\/span><\/td>\n<\/tr>\n
1<\/span><\/td>\nPIC16F877A<\/span><\/td>\n<\/tr>\n
1<\/span><\/td>\nBreadboard<\/span><\/td>\n<\/tr>\n
1<\/span><\/td>\nJumper Wires Pack<\/span><\/td>\n<\/tr>\n
7<\/span><\/td>\n330\u03a9 Resistors<\/span><\/td>\n<\/tr>\n
1<\/span><\/td>\n4MHz Crystal OSCillator<\/span><\/td>\n<\/tr>\n
1<\/span><\/td>\nLM7805 Voltage Regulator<\/span><\/td>\n<\/tr>\n
1<\/span><\/td>\n9v Battery or any Power Supply Source<\/span><\/td>\n<\/tr>\n
1<\/span><\/td>\nPICkit3 (PIC Programmer)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/h3>\n
\n

\u00a0 \u00a0What Are 7-Segments Displays?\u00a0 \u00a0<\/span><\/strong><\/span><\/h3>\n

The 7-segments is a simple electronic device that includes 7-LED bars arranged in such a way that represents decimal numbers [0 – 9] it also can be used to display hexadecimal digits [0 – F]. However, these devices actually have an eighth LED that represents the decimal point.<\/span><\/p>\n\n\n\n
\"7-segment<\/td>\n\"\"<\/td>\n\"7segments<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

The 7-segments displays are being used for simple display tasks within multiple applications (e.g. heaters, boilers, DVD players, audio players, wearable gadgets, digital locks, etc.).<\/span><\/p>\n

Learning how to interface the 7-segments display will help you create user-friendly applications. Let’s imagine that you’re creating The X-Machine <\/strong>which could be a boiler for example or whatever. Your device is supposed to show the user it’s current temperature value. Though you can possibly write the temperature’s (binary) value to an output port and hook some LEDs to show this number. Well, can you imagine how terrible this could be?<\/span><\/p>\n

\"X-Machine\"<\/p>\n

OMG, It’s annoying indeed. Your machine could only be shipped to expert users with knowledge in digital systems. However, it’s not guaranteed to sell any pieces at all.<\/span><\/p>\n

[click_to_tweet tweet=”The key to success in our industry is to design your system with the user in mind” quote=” The key to success in our industry is to design your system with the user in mind” theme=”style2″]<\/p>\n


\n

\u00a0 \u00a0How 7-Segments Actually Works?\u00a0 \u00a0<\/span><\/strong><\/span><\/h3>\n

There are two types of 7-segments for each model namely “Common Cathode” and “Common Anode”. This refers to the internal connection polarity convention of the LED bars. The difference is shown in the figure below.<\/span><\/p>\n

\"7Segments<\/p>\n

As you may have noticed, these devices are basically some LEDs hooked together in DIP packages. Hence the ease in operating\/interfacing 7-segments. It’s no more than some LEDs could be hooked to i\/o ports via 330\u03a9 resistors and be easily controlled. However, you should pay attention to the following couple of pints<\/span><\/p>\n