By then whenever we press the button the pin will be held to ground as shown in the connection diagram above. Since we said that B0 is used as input, we will connect one end of the pushbutton to the pin B0 and other end to the ground. The lines TRISD = 0x00 PORTD=0x00 will make all the pins of port D as Output and assign a initial value of LOW to those pins. The line TRISB0=1 will make the 0th pin of PORT B as input. The word TRIS is used to define if the pin is being used as input/output and the word PORT is used to make a pin High/Low. TRISD = 0x00 //Instruct the MCU that all pins are output TRISB0=1 //Instruct the MCU that the PORTB pin 0 is used as input for button. The best way to understand any program is to start from the main ( void main ()) function, so let's do that The first few lines are for setting up configuration bits which were explained in the previous tutorial so I am skipping them for now. I would recommend you to compare the output shown in video with the code below and try to understand the program. In order to understand the sequences please watch the video at the end of the tutorial. This code will start to glow LEDs in a sequential manner when the push button is pressed. PIC Microcontroller PIC16F877A LED Blinking Sequence Code and Working Explanation:Ĭomplete Code has been given below (check at the end), here we will get it through line by line. We will also add a pushbutton to initiate the sequence LED blinking. The LED board is nothing but another perf board, on which we will solder the LED's with a current limiting Resistor (shown below). At the end of this tutorial we will Generate a Sequence of Blinking LEDs using PIC microcontroller PIC16F877A and will learn how to use multiple inputs and outputs, some basics on ‘for’ loop and function calling. For this tutorial we will use the old Perf board (shown below) and will add berg sticks to pull out the required pins onto the second LED board. We will use 7 outputs (LEDs) and one Input. Now, in this tutorial we will advance our self to using more pins on the PIC microcontroller. Then we used PICkit 3, ICSP and MPLAB IPE for dumping the program onto our Perf board. In our previous tutorial, we learnt about Blinking a LED using PIC microcontroller and built the same circuit on Perf board.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |