Product successfully added to your shopping cart
4.50 JD Add to cart
0.10 JD Add to cart
6.00 JD Add to cart
0.15 JD Add to cart
Every time you learn a new programing language you meet the "Hello World!" program but in microcontrollers world the first program is "LED Blinking", PIC16F877A has 33 eneral Purpose Input output pins (GPIO),which could be used as input or output by configuiring the corespondiiing.
In the next figure TRIS register value is 00110101
In this lesson we will use MikroC enviroment to write
Maybe the main goal of this lesson is to lear how to get PIC16f877A running the code inside it. Here is the required connection for our LED Blinking.
Like any microcontroller we need an oscillator for our PIC16f877A, you can see it connected to pins 13 and 14. the oscillator value
Another thing to note is the reset button circuit, it's a simple circuit that drive the Master Clear (MCLR) pin always to High voltage to keep normal operation of the microcontroller unless the bush button is pressed, at that moment the MCLR pin is grounded and the microcontroller resets the operation of the code.
You migh also noticed that there are two VCC and two VSS pins, this is nessesary to spread the heat generated by current flow.
void main ()
TRISD= 0b11111110; // set bit0 to output and other bits to input
PORTD=1; // LED ON , bit0 of portd --> 1
Delay_ms(100); // Some time delay so we could notice the blinking
PORTD=0x00; // LED OFF,bit0 of portd --> 0
Delay_ms(100);//100 ms delay
|void main() |
| All of your projects should have both the main function and the endless loop.The main() function in C language|
projcts is the function that the processor works in and call other functions from.
As you noticed we used the binary format supported by mikroC, by starting with 0b and filling 8 bits
The forever loop, you dont need your programe to be excuted once, you need it to keep working for ever. the for ever loop
In our circuit we have connected the led to bit0 of PORTD so by setting bit0 to 1 the LED is on and by clearing it to zero the LED is off.
To make it possible for us to notice the blinking we need a time delay between the On/Off states. without this you will see the LED ON all the