Problems with Microcontroller Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you the Codes for Registered Members of this site only, at free service...Follow Me.

3-bit LED Up Counter

This is the first and the simplest project we are going to test on our PIC12F683 experiment board. We are going to make a 3-bit up counter that counts from 0 to 7. After 7, we are going to reset it to 0 and then start again, and so on. The 3-bit counter output will be displayed on 3-LEDs on the board. There will be a 1s delay between each up count.
Setup:
Connect GP0, GP1, and GP2 (pins 7, 6, and 5 of PIC12F683) to LEDs 3, 2, and 1 respectively.

 
Connect GPIO2, 1, 0 pins to LEDs 1, 2, 3 using jumper wires.

Software:

/*
  PIC12F683 Experiment Board
  Experimen No. 1 : 3-bit Up Counter
  "LEDs 1, 2, and 3 are connected to GPIO2, GPIO1, and GPIO0
   respectively"
*/

short i;
void main() {
CMCON0 = 7;
TRISIO = 8;  // GPIO0-GPIO2 are Outputs
ANSEL = 0;
GPIO = 0;
delay_ms(500);
i=0;
do {
   GPIO=i;
   delay_ms(1000);
   i = i+1;
   if(i == 8) i=0;

   }while(1);
}

Output:
3 LEDs count up to 7, then reset and count starts again.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Recent Comments

Popular Projects

Give Support

Give Support
Encourage Me through Comments

Microcontroller Projects

Total Pageviews