This exercise is to be implemented on the PIC Microtrainers in the Micros Laboratory using a PIC16F877A microcontroller. Patch wires are to be connected from the sockets of PORTD to the inputs of the 3 Digit 7 Segment Display LED’s such that Bit 0 connects to segment a, Bit 1connects to segment b and so on. Another patch wire is to be connected from the output of the potentiometer (labelled POT 0-5 Volt) to the PORTA bit 0 socket. The 3 LED displays will be controlled by connecting patch wires from PORTE Bits 2, 1, 0 to Digits 1, 2 and 3 repsectively.
Write a program which will read an analogue voltage from the potentiometer, convert it into an 8-bit binary number and produce a display on the LED’s such that the 7 segment display will display a number in denary (base 10) between 000 and 255 to represent a voltage between 0 and 5 Volts. The program should cycle round continually updating the display.
The program will also be able to display the A/D result in Octal (base 8) when a switch connected to bit 0 of Port B is high (logic 1).
1. Using MPLAB, develop and debug a program to carry out this task. Once it is working in the simulator, burn the program into the Microcontroller and try running it in the PIC Trainer.
2. The code required to use the 7 Segment Display on the 16F877A and possible algorithms to develop the rest of the codes.