is there any fault in my coding . i'm building elevator

General discussion on mikroBasic.
Post Reply
Author
Message
zeyad
Posts: 3
Joined: 01 Mar 2016 15:59

is there any fault in my coding . i'm building elevator

#1 Post by zeyad » 01 Mar 2016 16:57

i'm building elevator ground plus two storey . following is my code. is there any error in it?
i am not able to achieve my task

Code: Select all

 
function1(){
PORTD.F6=0;
PORTD.F7=1;
if(PORTB.F4!=1){
delay_ms(100);
if(PORTB.F4!=1){
PORTD.F6=0;
PORTD.F7=0;
}
}
}
 function2(){
PORTD.F6=0;
PORTD.F7=1;
if(PORTB.F5==0){
PORTD.F6=0;
PORTD.F7=0;
}
 }
 function3(){
PORTD.F6=1;
PORTD.F7=0;
if(PORTB.F4==0){
PORTD.F6=0;
PORTD.F7=0;
}
}
 function4(){
PORTD.F6=1;
PORTD.F7=0;
if(PORTB.F3==0){
PORTD.F6=0;
PORTD.F7=0;
}
}
 function5(){
PORTD.F6=0;
PORTD.F7=1;
if(PORTB.F5==0){
PORTD.F6=0;
PORTD.F7=0;
}
}
 function6(){
PORTD.F6=1;
PORTD.F7=0;
if(PORTB.F3==0){
PORTD.F6=0;
PORTD.F7=0;
}
}

int main() {
  TRISB.F0=1;
  TRISB.F1=1;
  TRISB.F2=1;
  TRISB.F3=1;
  TRISB.F4=1;
  TRISB.F5=1;
  TRISD.F6=0;
  TRISD.F7=0;
  PORTD.F6=0;
  PORTD.F7=0;
while(1){
if(PORTB.F3==0 && PORTB.F1==0){
function1();

}
if(PORTB.F4==0 && PORTB.F2==0){
function2();
}

if(PORTB.F5==0 && PORTB.F1==0){
function3();
}
if(PORTB.F4==0 && PORTB.F0==0){
function4();
}
if(PORTB.F3==0 && PORTB.F2==0){
function5();
}
if(PORTB.F5==0 && PORTB.F0==0){
 function6();
}
}
}

Post Reply

Return to “mikroBasic General”