Wednesday, 29 October 2014

8051 Microcontroller interfacing with seven segment using Embedded C and simulation over proteous.

   
//this program run and compile with kiel uvision 3
// Here is your program :-
#include<reg51.h>
#define SegmentPort P1   //this line assigne variable segmentport to port P1

void MsDelay(int x) ;   //delay function prototype
void main()
{     
    unsigned char z,x ;
  char MyArray[]={0xc0,0xf9,0xA4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff} ;
    //this array content hex value equal to 0 to 9 decimal values this value can be change according to seven segment.
  SegmentPort = 0x00 ;  //here P1 define as a output port
   while(1)
    {
          for(z=0;z<=11;z++)
           {
                   P2 = MyArray[z] ;
                   MsDelay(4000); //this will generate 4 second delay
                   }

void MsDelay(int x) //this function takes value to generate dealy
{
        int i;
        for(i=0;i<x;i++)
        {
           TH0=0xFC;  //this values generate 1 ms delay but we write this code
           TL0=0x18; //in for loop this mean if we entere 4000 it will gives 4 sec   
            TR0=1;  // of delay
                while(TF0==0);
                TR0=0;
                TF0=0;
        }
 }



Proteous interfacing of seven segment with 8051 controller



No comments:

Post a Comment

Compiler for C,C++ and Python {paste your programme to see the output}