I/O devices (input and output devices) are essential components of microcontroll
ID: 2081585 • Letter: I
Question
I/O devices (input and output devices) are essential components of microcontroller-based systems. The PIC18F microcontroller communicates with five I/O ports, PORT A through PORT E. Each I/O port is associated with the special function registers (SFR) to set up different functions. Common output devices and switches are LEDs, LCD, and seven-segment LED displays. Keypad matrixes are the common input devices for PIC18.
The figure shown above is a seven-segment display. A seven-segment display is another type of I/O port output module. It is a group of 7 LEDs (segments) physically built up in the form of the number 8 and a decimal point, as illustrated in Figure 1. It is used to show decimal numbers 0 through 9 and alpha characters A through F.
In this activity, you will be designing a program to display “E307” using four seven-segment displays in PIC18 Simulator.
Please provide code to generate the E307 reading.
b e C dpExplanation / Answer
code:
#include <xc.h>
#define Seven_Segment1 LATA
#define Seven_Segment2 LATB
#define Seven_Segment3 LATC
#define Seven_Segment4 LATD
void main(void)
{
TRISA = 0xFF;
TRISB = 0xFF;
TRISC = 0xFF;
TRISD = 0xFF;
Seven_Segment1 = 0b00011001; // 'E'
Seven_Segment2 = 0b01001111; // '3'
Seven_Segment3 = 0b00111111; // '7'
Seven_Segment4 = 0b00000111; // '0'
while(1);
return;
}