Many electronics circuits and projects for learning in simple ways.

PIC microcontroller 2 led flasher circuit using PIC16F627

Today, We will try the PIC microcontroller 2 led flasher circuit using PIC16F627.
Because like this circuit Which we can set ON-OFF of both LEDs for easy, long and accurate.

Note: I intend to teach his son, love electronics, He likes to experiment with the electronic projects For the fun. Since this time He was 8 years old. I avoid hard content, We can apply for the simple microcontroller circuit only and modify them through a simple C compiler code. Do not need to understand all the work. It may be that he was wary of the microcontroller.

How it works

First time you should read at : this circuit

First of all, you must connect the circuit as Figure 1.

2-LED-Flasher-circuit-PIC16F627A

Second, Assemble all equipment into the breadboard as Figure 2
Assemble-all-equipment-into-the-breadboard

Then, we write Hex code into IC1 Please read how to here!
1. we type C+ code on mikroC compiler for PIC as below:

main()
{
TRISA = 0xFC;
while(1)
{
PORTA = 0x01;
Delay_ms(500);
PORTA = 0x02;
Delay_ms(500);
}
}

Parts you will need
IC1____PIC16F627A PIC Micro controller IC
R1_____4.7K 0.5W Resistor
R2-R3__470 ohms 0.5W Resistors
C1,C2___22pF 50V Ceramic capacitors
X-tal____ 3.579545 MHz crystal
LED1,LED2___LED as you want

The experimental results
When applying the 5 volts power supply to the circuit.
LED1 at Pin 17 will light up “ON” before for 0.5 seconds then it is OFF for 0.5 seconds.
And while LED2 at Pin 18 will light up instead for 0.5 seconds, next to LED 2 is OFF for 0.5 Second.
And LED1 back to light up again. the LEDs alternately flash ON and OFF about 0.5 seconds.

Both LEDs will flash equal 0.5S or 500mS as Code.

testing_2LED-flasher-circuit-pic16f627a


LED ‘s flashing modification

We try to modify the flashing of LEDs by changing to 500 to 3000 (or 3000mS or 3S), please look code below this.

1. LED1 will light up a 3 second, and LED2 will still light 0.5S As Video

Code modification for LED1

main()
{
TRISA = 0xFC;
while(1)
{
PORTA = 0x01;
Delay_ms(3000); <==== For control LED1 ON at pin 17
PORTA = 0x02;
Delay_ms(500); <==== For control LED2 ON at pin 18
}
}


LED1 turn on = 3S; LED2 turn on 0.5S

2. Then we edit code for LED1 is 500 again. And edit other code is 3000 as the code below.

Code modification for LED2

main()
{
TRISA = 0xFC;
while(1)
{
PORTA = 0x01;
Delay_ms(500); <==== For control LED1 ON at pin 17
PORTA = 0x02;
Delay_ms(3000); <==== For control LED2 ON at pin 18
}
}

Makes LED1 turn ON = 0.5S and LED 2 turn ON a longer stretch of time is 3 second.


LED1 turn ON = 0.5S; LED2 turn ON = 3S

Just as we can use it
From the top, we just experiment with changing the code number for mS time unit. We not change any hardware circuit and Not require any capacitor, making very precise timing.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu