Hi Guys,
Now I know that for trapping a button being pressed ...the normal condition is to present either a 1 (5V) or a 0 (0V) at an input pin.
However, is it possible to have a PIC trap a button being pressed with a voltage somewhere in between?
Is it possible to present say 2.5V at a PIC input pin & have button press code along the lines of "if input pin x isn't high then goto"
This is just curiosity really - can it be done? (it just so happens I run a lot of virtual ground circuits where there's 2.5V presented all over the place...so it might be useful!
PS I'm having a torrid time getting PIN 4 on a 12F683 to work as an digital output pin - this just so happens to be the MCLR pin - any top tips what might be my problem? if I use the same code but with a different pin in it's place it all works - so it's somethint unique to that pin 4 - I've tried the MCLRE_OFF in my config - it's driving me potty...
What am I missing?Code:@MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF @MyConfig = MyConfig & _MCLRE_OFF DEFINE OSC 4 ' Internal 4MHz DEFINE ADC_BITS 10 ' 10-bit resolution DEFINE ADC_CLOCK 2 ' Set clock source to Frc/32 DEFINE ADC_SAMPLEUS 50 ' Sample time in uS before A/D conversion is started DEFINE DEBUG_REG GPIO ' Define DEBUG port DEFINE DEBUG_BIT 0 ' Set GPIO.0 as DEBUG serial output pin DEFINE DEBUG_BAUD 9600 ' DEBUG baud rate = 9600 bps DEFINE DEBUG_MODE 0 ' 1 = inverted, 0 = true CMCON0 = 7 'Comparators off ANSEL = %00001000 'AN3 'Signal In' GPIO.4 (pin 3) INTCON = 0 'INTERRUPTS off TRISIO = %11110011 'All Inputs except GPIO.2 (Pin 5) & GPIO.3 (Pin 4 ) VRCON = %00000000 'VREF Off
tks!






Bookmarks