thanks for all for help me
this is the last code i write
Code:
void main(){
char oldstate = 0;
int x;
TRISB = 0xFF; // set PORTB to be input
TRISD = 0; // set PORTD to be output
PORTD = 0x0F; // initialize PORTD
do {
if (Button(&PORTB, 1, 1, 1)) // detect logical one on RB1 pin
oldstate = 1;
if (oldstate && Button(&PORTB, 1, 1, 0)) {
// detect one-to-zerotransition on RB1 pin
for(x=0;x,1000;x++)
{
//code of my project
PORTd=0;
Delay_us(337);
PORTd=0B00000101;
Delay_us(2717);
PORTd=0B00001001;
delay_us(3889);
PORTd=0B00000101;
delay_us(2667);
PORTd=0;
delay_us(777);
PORTd=0B00000110;
delay_us(2667);
PORTd=0B00001010;
delay_us(3889);
PORTd=0B00000110;
delay_us(2667);
PORTd=0;
delay_us(388);
}
// negates value on PORTD
oldstate = 0;
}
} while(1); // endless loop
}
and when i press on the nswitch connected to pin RB1 the program run
iam very happy and thanks for all one try to help me
but was the error is that i was connect the switch to port A instead of port B
or what is the wrong in all the previous codes
thanks alot for all