Difference between revisions of "Seven Segment with PIC16F877A Starter Board"
Line 1: | Line 1: | ||
[[Category:Starter PIC16F877]] | [[Category:Starter PIC16F877]] | ||
− | + | =Code= | |
+ | <html> | ||
+ | <script src="https://gist.github.com/sharanago/3faf33290eefe9d8823df381cfc8f38d.js"></script> | ||
+ | </html> | ||
=Demo= | =Demo= | ||
[[File:Pic16f877a seven segment.gif]]<br><br> | [[File:Pic16f877a seven segment.gif]]<br><br> |
Latest revision as of 12:44, 28 April 2016
Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <pic16f877a.h> | |
#define Segment 0x01 | |
void DELAY_ms(unsigned int ms_Count) | |
{ | |
unsigned int i,j; | |
for(i=0;i<ms_Count;i++) | |
{ | |
for(j=0;j<1000;j++); | |
} | |
} | |
int main() { | |
char seg_code[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e}; | |
int cnt; | |
/* Configure the ports as output */ | |
TRISB = 0x00; // Data lines | |
TRISD = 0x00; // Control signal PORTD0 | |
while (1) | |
{ | |
for (cnt = 0x00; cnt < 0x10; cnt++) // loop to display 0-F | |
{ | |
PORTD = Segment; | |
PORTB = seg_code[cnt]; | |
DELAY_ms(300); | |
} | |
} | |
} |