Microcontroller › PIC › Novice at Microcontrollers › I’m using MPLAB IDE v8.88 and
I’m using MPLAB IDE v8.88 and c18 compilier and I got an LED to light reading input by using a sample program on this site but, I have a major problem, before I can even sent 5V on portb to send it high, the LED on porte lights, matter of fact any wire, slight touch on any of the portb input pins causes it the LED on pote to light or stay on for a while, worst case it just comes on and stays on. The next problem is that, the porte output is about 2.5V max. From the looks of things I’m in deep trouble, here is the code.
//config.
#include <p18F4550.h>
#pragma config FOSC = INTOSC_EC
#pragma config PWRT = OFF
#pragma config BOR = OFF
#pragma config MCLRE = ON
#pragma config PBADEN = OFF
#pragma config ICPRT = OFF
#pragma config LVP = OFF
#pragma config WDT = OFF,DEBUG=OFF
void main()
{
ADCON1=0x0F; // Set all pins as digital I/O
CMCON=0x07; // Set all comparators as digital I/O
TRISEbits.RE0=0; // Configure pin RE0 as output
TRISBbits.RB0=1; // Configure pin RB0 as input
while(1)
{
if(PORTBbits.RB0=1) // If input is high
LATEbits.LATE0=1; // Turn the LED On
else
LATEbits.LATE0=0; // Turn the LED Off
}
}