I am doing a simple program with my PIC (PIC24FJ1024GB610).
When a button is pressed the LED is turned on, when it is released LED is turned off.
I presumed that the input pins have a pullup resistor connected to it inside the microcontroller by default, because when I measured the voltage across the pin when it was floating, it was 3.3V
simulate this circuit – Schematic created using CircuitLab
In a pull-up configuration, Vinput is 3.3V when the button is released, and 0V when the button is pressed.
However, when the button is pressed or released I measured the same value which is 3.3V
I am using a breadboard to design the circuit, and a pic development board: Explorer16/32
I added the code FYI.
#include "System.h"
#include <xc.h>
/*
P44 is input RB15
P88 is output RF1 5V tolerant
*/
#define ANALOG 1
#define DIGITAL 0
#define INPUT 1
#define OUTPUT 0
//BTN RB15
#define BTN_ANS ANSBbits.ANSB15
#define BTN_TRIS TRISBbits.TRISB15
#define _INPUT PORTBbits.RB15
//LED RF1
#define LED_TRIS TRISFbits.TRISF1
#define _OUTPUT _LATF1
int main (void)
{
//LED_ANS = DIGITAL;
LED_TRIS = OUTPUT;
_OUTPUT = 0;
BTN_ANS = DIGITAL;
BTN_TRIS = INPUT;
while(1)
{
if(_INPUT == 1)
_OUTPUT = 1;
else
_OUTPUT = 0;
}
return 0;
}