To get a "MCLR is low voltage" error means you have too much loading on the MCLR pin. Do you have a pullup resistor from MCLR to Vdd?
i already try put pullup resistor on MCLR, 47K ohm or 3.3K ohm... still same...
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
To get a "MCLR is low voltage" error means you have too much loading on the MCLR pin. Do you have a pullup resistor from MCLR to Vdd?
What are you using to power your PIC?
I can't remember if you mentioned it yet or not.
Make sure you're not putting 12 volts in where you should be providing 5 volts. That will give you the high voltage error.
#define LED_DIR TRISB7_bit
#define SW1_DIR TRISB0_bit
#define SW1_PIN RB0
#define LED_PIN RB7
void main() {
while(1) // continually
{
LED_DIR = 0;
SW1_DIR = 1;
if (SW1_PIN) // if the switch is at logic one
{
LED_DIR = 0; // turn the LED off
}
else
{
LED_DIR = 1; // otherwise, flash LED one time
delay_ms(200);
LED_DIR = 0;
delay_ms(200);
}
}
}
Sorry, I see what you mean.
You are aware that pushed switch will give you a 0 and not a 1, correct?
Do you want it to flash the light when the switch is pressed or if it's not pressed?
You said you're receiving an error, correct? A high voltage error?
Perhaps I should read back over this thread to pick up what I missed
Matt
the high voltage error the one that i want to test program PIC using training kit but just use jumper from the needed pin(PIC) to ZIF socket(TrainingKIt)...
the new post is new problem... ya if push switch it will give 0 cause go to ground maybe... if i press the switch it will on the LED...
Right, I think you'll want to change that to if (sw1_pin==0).
Also, are you remembering to load your code onto the pic in the simulator?
ya i already loaded the code into PIC here with simulation log :
View attachment 72183
if i put LED into pin RB0 which i code for SW1, and SW1 to pin RB7 which is code for LED... it work but got error message with logic contention detected... when i change and fix the error by put back the input and output pin to exact location, i cant even on when push the button...
Edit : i also try (sw1_pin==0) but still same...
I'm asking if you could copy and paste the error, or show a screenshot of it. All you've shown us so far is the circuit and a working simulation log.
#define LED RB7_bit
#define SW RB0_bit
void main()
{
TRISB7_bit=0x00;
LED=0;
TRISB0_bit=1;
PORTB=0;
while(1)
{
if(SW==0)
{
if(LED==1)
{
LED=1;
}
else if(LED==0)
{
LED=0;
}
}
else if(SW==1)
{
if(LED==1)
{
LED=0;
}
else if(LED==0)
{
LED=1;
}
}
}
}