Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

problem with elevator project pic16f877A

Status
Not open for further replies.

osm3000

New Member
I'm building a very simple project , which is the elevator control system.
every button represents a floor . for example , if the elevator x is in floor 1 & i pressed the button of the 4th floor , then the 7-segment will count form 1 up to 4.
the problem is that there is no output at all.
the code is for mikro c compiler.
the attached folder contains the proteus simulation.

**broken link removed**

another question : I'm using CCS & mikroC compilers , but many people advised me against CCS and in favor of mikroC ,,, form your experience , what do you prefer ?

The code for mikroC

void main() {
int x=0; // the elevator
int i = 0; //counter
int n[10] = {63,6,91,79,102,109,125,7,127,111}; //for the 7-seg output
TRISB=0; //OUTPUT
TRISD=0xff;
/*
D0 is the ground
D1 is the 1st floor
D2 is the 2nd floor
D3 is the 3rd floor
D4 is the 4th floor
D5 is the 5th floor
*/
portb=n[0];
while(1)
{
//ground floor
if (portd.B0==1)
{
if (x>0)
{
for(i = x;i<=0;i--)
{
PORTB=n;
;
}
x = 0;
}
else
{
PORTB=n[0];
x =0;
}
}
/////////////////////////1st floor
if (portd.B1==1)
{
if(x>1)
{
for(i = x;i<=1;i--)
{
PORTB=n;
;
}
x = 1;
}
else if (x<1)
{
for (i=x;i>=1;i++)
{
PORTB=n;
;
}
x=1;
}
}
/////////////////////2nd floor
if (portd.B2==1)
{
if(x>2)
{
for(i = x;i<=2;i--)
{
PORTB=n;
;
}
x = 2;
}
else if (x<2)
{
for (i=x;i>=2;i++)
{
PORTB=n;
;
}
x=2;
}
}
//////////////////////3rd floor
if (portd.B3==1)
{
if(x>3)
{
for(i = x;i<=3;i--)
{
PORTB=n;
;
}
x = 3;
//output_B(n[3]);
}
else if (x<3)
{
for (i=x;i>=3;i++)
{
PORTB=n;
;
}
x=3;
}
}
/////////////////////4th floor
if (portd.B4==1)
{
if(x>4)
{
for(i = x;i<=4;i--)
{
PORTB=n;
;
}
x = 4;
}
else if (x<4)
{
for (i=x;i>=4;i++)
{
PORTB=n;
;
}
x=4;
}
}
/////////////////////5th floor
if (portd.B5==1)
{
if(x>5)
{
PORTB=n;
x = 5;
}
else if (x<5)
{
for (i=x;i>=5;i++)
{
PORTB=n;
;
}
x=5;
}
}
}
}
 

Attachments

  • 8888.JPG
    8888.JPG
    150 KB · Views: 3,366
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top