


#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) Launch the MPLABX program and create new project, let us start with the configuration bits. Let us increment a variable from 0 to 1000 and print it on the 7-segment display.
#Anode cathode pic how to
Now, that we know how this module actually works, let us learn how to program PIC16F877A to make it display a 4 digit number. Note: Ground pin of the module should also be connected to the ground of the MCU which is not shown here. Hence all the 8 character pins are assigned to PORTD and the display selection pins are assigned to first four pins of PORTC. We have 12 output pins from the module out of which 8 is used to display the characters and four is used to select one display out of four. Here we have used PIC microcontroller PIC16F877A and the schematic for the circuit is shown below. Simply we can select which display has to go active using the pins from D0 to D3 and what character to be display using the pins from A to DP.Ĭonnecting 4-Digit Seven Segment Module with PIC Microcontroller: For example: If I need my output to be present only on the second display then only D1 should be made high while keeping other pins (D0, D2, and D3) as low. We have additional four pins from D0 to D3 (D0, D1, D2 and D3) which can be used to control which display out of the four should go high. So, basically if trigger A on, then all four A's should go high right?īut, that does not happen. To understand how 4-digit seven segment module works we have to look into the above schematics, as shown the A pins of all four display is connected to gather as one A and the same for B,C.

The connection schematic for the same is shown below: We know that each 7-segment module will have 10 pins and for 4 seven segment displays there would be 40 pins in total and it would be hectic for anyone to solder them on a dot board, so I would highly recommend anyone to buy a module or make your own PCB for using a 4-digit 7-segment display. So, in this tutorial we will be using a 4-digit 7-Segment Display Module as shown below.Īs we can see there are Four Seven Segment Displays connected together. But, it is pretty evident that we would need more than one 7-segment display to convey any information that is more than one digit. Now we know how to display our desired numeric character on a single 7-segment display. There are two types of 7-segment displays: Common Cathode and Common Anode, here we are using Common Cathode seven segment display. Like if you want the 7-segment to display the number "5" then you need to glow segment a,f,g,c, and d by making their corresponding pins high. So, let us start knowing it.ħ-Segment and 4-Digit 7-Segment Display Module:ħ Segment Display has seven segments in it and each segment has one LED inside it to display the numbers by lighting up the corresponding segments. 7-segments also have the advantage against poor lighting condition and can be viewed from lager angles than a normal LCD screen. LCD suffers from the drawback of having low character size and will be overkill for your project if you are just planning to display some numeric values. In our last tutorial we saw how we can generate Custom characters with our 16*2 LCD display, now let us equip our self with another type of display module called the 7-segment display and interface it with PIC Microcontroller.Īlthough 16x2 LCD is much more comfortable than 7-segment display but there are few scenarios where a 7-segment display would come in handier than a LCD display. If you are new here, then look at previous tutorials where you can learn timers, blinking LED, interfacing LCD etc. We have come up all the way from installing MPLABX to using a LCD with PIC MCU. This is our 8th tutorial of Learning PIC microcontrollers using MPLAB and XC8.
