baby_1
Advanced Member level 1
hello my friends
i wrote this program
#include <p18f452.h>
#pragma config WDT=OFF
#pragma config OSC=HS
#define baby1 PORTBbits.RB5
int baby;
void main(void)
{
TRISD=0;
TRISBbits.RB5=1;
PORTD=255;
while(1)
{
if(baby1==0)
{
PORTD=~PORTD;
for(baby=0;baby<=30000;baby++);
}
}
}
it has some problems that i can't understand:
when i power up my circuit PORTD=0 it against of that i set the PORTD=255 , why?
i put a swicth button on RB5 and ground another pins of switch putton and i pull up the RB5 with a 4.7Kohm resistor ,when i press it the statues of portd set to 1 but it leaves its status when i unpress it.why?
excuse if my english is poor
---------- Post added at 18:01 ---------- Previous post was at 17:37 ----------
it works in Proteus but in reality doesn't work
i wrote this program
#include <p18f452.h>
#pragma config WDT=OFF
#pragma config OSC=HS
#define baby1 PORTBbits.RB5
int baby;
void main(void)
{
TRISD=0;
TRISBbits.RB5=1;
PORTD=255;
while(1)
{
if(baby1==0)
{
PORTD=~PORTD;
for(baby=0;baby<=30000;baby++);
}
}
}
it has some problems that i can't understand:
when i power up my circuit PORTD=0 it against of that i set the PORTD=255 , why?
i put a swicth button on RB5 and ground another pins of switch putton and i pull up the RB5 with a 4.7Kohm resistor ,when i press it the statues of portd set to 1 but it leaves its status when i unpress it.why?
excuse if my english is poor
---------- Post added at 18:01 ---------- Previous post was at 17:37 ----------
it works in Proteus but in reality doesn't work