My code works fine with pull down resistors, however it does not work with pull up resistors; How would I need to modify the button press code to work with pull up resistors? I need to have two switches that change modes independently.
Code: Select all
' Mode Changing Code - Detects input on B6 and B7 and acts accordingly
if(oldr7 <> PORTB) THEN 'Check to see if primary mode changed
oldr7 = PORTB 'Snapshot of current button states
if PORTB.RB7 = 1 THEN 'If Primary Button was pressed increment the mode
delay_ms(300) 'Short pause to give the user time to get off the button
if inc(mode) >= MAX_MODE THEN mode = 0 END IF 'If we've passed the max # of modes then start over
mode2=0 ' Make sure we reset the sub mode counter
dir1 = 0 ' make sure we clear the PWM direction
PORTC = 00000000 ' always clear the LEDs on PORTC
if mode = 3 then
p1 = %11111100
curzone = 1
end if
if PORTB.RB6 = 1 THEN 'Check to see if sub-mode changed
inc(mode2) 'Increment the value of mode2 (sub-mode)
random = 0
delay_ms(300)
END IF