0leee
Member level 2
i need help;this program works in teory and on simulator,but in real life i do not thinks so;so i need help if enyone wants
to help me ,what i should do to this program work in real life too?
//With one switch speeding with second unspeeding//
#include<htc.h>
#define _XTAL_FREQ 20000000
main()
{
int counter=0;
TRISA=0b11111111;
TRISB=0b11111111;
TRISD=0b00000000;
while(1){
//LED power indicator//
RD5=1;
__delay_ms(100);
RD5=0;
__delay_ms(100);
//speeding;//
if(RA4==0){
while(RA4==0)continue;
counter++;
}
//un speeding//
if(RB0==0){
while(RB0==0)continue;
counter--;
}
//counters that i do not want//
if(counter==-1)counter=0;
if(counter==6)counter=5;
//speed with"n"counter//
if(counter==0){RD6=0;}
if(counter==1){RD6=1;__delay_us(2000);RD6=0;__delay_us(8000);}
if(counter==2){RD6=1;__delay_us(4000);RD6=0;__delay_us(6000);}
if(counter==3){RD6=1;__delay_us(6000);RD6=0;__delay_us(4000);}
if(counter==4){RD6=1;__delay_us(8000);RD6=0;__delay_us(2000);}
if(counter==5){RD6=1;}
}
}
to help me ,what i should do to this program work in real life too?
//With one switch speeding with second unspeeding//
#include<htc.h>
#define _XTAL_FREQ 20000000
main()
{
int counter=0;
TRISA=0b11111111;
TRISB=0b11111111;
TRISD=0b00000000;
while(1){
//LED power indicator//
RD5=1;
__delay_ms(100);
RD5=0;
__delay_ms(100);
//speeding;//
if(RA4==0){
while(RA4==0)continue;
counter++;
}
//un speeding//
if(RB0==0){
while(RB0==0)continue;
counter--;
}
//counters that i do not want//
if(counter==-1)counter=0;
if(counter==6)counter=5;
//speed with"n"counter//
if(counter==0){RD6=0;}
if(counter==1){RD6=1;__delay_us(2000);RD6=0;__delay_us(8000);}
if(counter==2){RD6=1;__delay_us(4000);RD6=0;__delay_us(6000);}
if(counter==3){RD6=1;__delay_us(6000);RD6=0;__delay_us(4000);}
if(counter==4){RD6=1;__delay_us(8000);RD6=0;__delay_us(2000);}
if(counter==5){RD6=1;}
}
}