16F84 Sample LED Circuit Diagram
16F84 Sample LED Circuit Diagram
PIC 16f84 Pin Diagram Power Regulator
78L05 is a very common regulator used to provide power to sensitive electronic devices like microcontrollers. Resonator
This is denoted as X1 in the circuit. You can use a 10-MHz resonator instead of oscillator and 2 capacitors. A Resonator is a combined unit of ceramic vibrator and capacitors. Some of the patters you can make can be illustrated below. You can use either C or ASM to write routines for this micro. You can use the Multi PIC programmer to program this device. Also see tutorial How to start with Microcontrollers to get an idea of the software tools required.
Hope this quick tutorial will give you a simple idea.
Re: 16F84 Sample LED Circuit Diagram
Hi All ,
some notes on above circuit diagram
(1) Here LED's have connected as current sink devices, That mean current flow into the micro controller. So
remember when you give signals from micro controller , to light up each LED , make the output pin LOW.
that mean when you want to ON the LED , make relevant output pin of MCU LOW. ( Not High as usual)
(2) You can increase the number LED's which can light up, with few micro controller pins from a method called multiplexing.
Bottom 5 lines are Cathodes. ( that mean we have to ground them)
If you look on the above 5 seventh segment displays , if you control them using normal way , we want 36 I/O pins in a micro controller. ( each Segment unit contain 7 LED's , so 7*5 + common ground = 36 )
But if we connect them as in the above diagram , we want only 12 I/O pins.
Here trick is you have to switch between segments , in some bit high frequency for display some thing in all 5 segments.
As Human eye can not identify the changes , which occur above 20 Hz , if you do this switching with a frequency larger than 20 Hz , you may display the content in segments ,even they do not have power.
Magneto
some notes on above circuit diagram
(1) Here LED's have connected as current sink devices, That mean current flow into the micro controller. So
remember when you give signals from micro controller , to light up each LED , make the output pin LOW.
that mean when you want to ON the LED , make relevant output pin of MCU LOW. ( Not High as usual)
(2) You can increase the number LED's which can light up, with few micro controller pins from a method called multiplexing.
Bottom 5 lines are Cathodes. ( that mean we have to ground them)
If you look on the above 5 seventh segment displays , if you control them using normal way , we want 36 I/O pins in a micro controller. ( each Segment unit contain 7 LED's , so 7*5 + common ground = 36 )
But if we connect them as in the above diagram , we want only 12 I/O pins.
Here trick is you have to switch between segments , in some bit high frequency for display some thing in all 5 segments.
As Human eye can not identify the changes , which occur above 20 Hz , if you do this switching with a frequency larger than 20 Hz , you may display the content in segments ,even they do not have power.
Magneto
Re: 16F84 Sample LED Circuit Diagram
Can any one give a code for this diagram????????? 

Re: 16F84 Sample LED Circuit Diagram
Hey, the fun part of Microcontrollers is programming mostly with ASM (though C is easier). After you make your hardware design by using your electronic skills (you can get advises from professionals like Magneto for this), the most fun part is to do programming. In my case, I'm mostly interested when there is a mathematics part involved
So please do not ask for codes. Firmware development is my everyday job so personally I don't have time to write codes for anybody. Magneto will not as well. You need to write your own code. However, you can ask questions that arise when you are coding.
We find time very hardly to write these tips since we believe we need to do something for young people like you. Please don't expect things to be done by us for you

So please do not ask for codes. Firmware development is my everyday job so personally I don't have time to write codes for anybody. Magneto will not as well. You need to write your own code. However, you can ask questions that arise when you are coding.
We find time very hardly to write these tips since we believe we need to do something for young people like you. Please don't expect things to be done by us for you

Code for 16F84 Sample LED Circuit Diagram
I wrote a simple code for above given Circuit Diagram.

Code: Select all
#include <pic.h>
#include "delay.h"
#define sleep 50 //set the time between changes in miliseconds
int start()
{
PORTB = 1;
if(RA0==0)
{
rata1(); //if RA0 is low then goto rata1
}
else if(RA1==0)
{
rata2(); //if RA1 is low then goto rata2
}
else if(RA2==0)
{
rata3(); //if RA2 is low then goto rata3
}
else if(RA3==0)
{
rata4(); //if RA3 is low then goto rata4
}
else if(RA4==0)
{
rata5(); //if RA4 is low then goto rata5
}
else {
start(); //if any RA is not low then goto start again
}
}
int rata1()
{
RB0=0; //set RB0 to low
DelayBigMs(sleep);//sleep a time
RB0=1; //set RB0 to high
RB1=0; //set RB1 to low
DelayBigMs(sleep);//sleep a time
RB1=1; //set RB1 to high
RB2=0; //set RB2 to low
DelayBigMs(sleep);//sleep a time
RB2=1; //set RB2 to high
RB3=0; //set RB3 to low
DelayBigMs(sleep);//sleep a time
RB3=1; //set RB3 to high
RB4=0; //set RB4 to low
DelayBigMs(sleep);//sleep a time
RB4=1; //set RB4 to high
RB5=0; //set RB5 to low
DelayBigMs(sleep);//sleep a time
RB5=1; //set RB5 to high
RB6=0; //set RB6 to low
DelayBigMs(sleep);//sleep a time
RB6=1; //set RB6 to high
RB7=0; //set RB7 to low
DelayBigMs(sleep);
start();//goto start after 1 round for cheking switches
}
int rata2()
{
RB7=0;
DelayBigMs(sleep);
RB7=1;
RB6=0;
DelayBigMs(sleep);
RB6=1;
RB5=0;
DelayBigMs(sleep);
RB5=1;
RB4=0;
DelayBigMs(sleep);
RB4=1;
RB3=0;
DelayBigMs(sleep);
RB3=1;
RB2=0;
DelayBigMs(sleep);
RB2=1;
RB1=0;
DelayBigMs(sleep);
RB1=1;
RB0=0;
DelayBigMs(sleep);
start();
}
int rata3()
{
RB3=0;
RB4=0;
DelayBigMs(sleep);
RB3=1;
RB4=1;
RB2=0;
RB5=0;
DelayBigMs(sleep);
RB2=1;
RB5=1;
RB1=0;
RB6=0;
DelayBigMs(sleep);
RB1=1;
RB6=1;
RB0=0;
RB7=0;
DelayBigMs(sleep);
RB0=1;
RB7=1;
DelayBigMs(sleep);
RB0=0;
RB7=0;
DelayBigMs(sleep);
RB1=0;
RB6=0;
RB0=1;
RB7=1;
DelayBigMs(sleep);
RB2=0;
RB5=0;
RB1=1;
RB6=1;
DelayBigMs(sleep);
start();
}
int rata4()
{
RB0=0;
DelayBigMs(sleep);
RB0=1;
RB1=0;
DelayBigMs(sleep);
RB0=0;
RB1=1;
RB2=0;
DelayBigMs(sleep);
RB0=1;
RB1=0;
RB2=1;
RB3=0;
DelayBigMs(sleep);
RB0=0;
RB1=1;
RB2=0;
RB3=1;
RB4=0;
DelayBigMs(sleep);
RB0=1;
RB1=0;
RB2=1;
RB3=0;
RB4=1;
RB5=0;
DelayBigMs(sleep);
RB1=1;
RB2=0;
RB3=1;
RB4=0;
RB5=1;
RB6=0;
DelayBigMs(sleep);
RB2=1;
RB3=0;
RB4=1;
RB5=0;
RB6=1;
RB7=0;
DelayBigMs(sleep);
RB3=1;
RB4=0;
RB5=1;
RB6=0;
RB7=1;
DelayBigMs(sleep);
RB4=1;
RB5=0;
RB6=1;
RB7=0;
DelayBigMs(sleep);
RB5=1;
RB6=0;
RB7=1;
DelayBigMs(sleep);
RB6=1;
RB7=0;*/
DelayBigMs(sleep);
start();
}
int rata5()
{
PORTB = 0;
DelayBigMs(sleep);
DelayBigMs(sleep);
DelayBigMs(sleep);
PORTB = 0xff;
DelayBigMs(sleep);
DelayBigMs(sleep);
DelayBigMs(sleep);
start();
}
main()
{
TRISB = 0; //set all RB 8pins as output
TRISA = 0xff; //set all RA 5pins as input
PORTB = 1; //set all RB 8pins high at startup
start(); //goto start function
}
Re: 16F84 Sample LED Circuit Diagram
Looks correct to me.
Try it on the Proteus or actual micro and confirm the code so others will benefit too.
Try it on the Proteus or actual micro and confirm the code so others will benefit too.
Re: 16F84 Sample LED Circuit Diagram
I tested this on Proteus before posting here. it worked correctly.