Hi Michael,
Try the following and post results. Where i am now i can't test it
Code:
' I am working on a delay project which uses 2 buttons one for increasing the
' delay and one for decreasing the delay. I am using the PIC16F84 and have a
'
' buttons:
' ========
' connected to PORTB pin 5,6.
' pin 5 : increase
' pin 6 : decrease
' LEDS:
' =====
' PORTB pin 4 : showing the length of the delay,
' pin 3 : showing when both buttons are pushed that it saves
' the delay to EEPROM,
' pin 7 : showing when IncreaseButton is pushed
'
' PORTA pin 3 for when DecreaseButton is pushed.
TRISB=%01100000 ' PORTB<6:5> as input
' others as output
'
TRISA=0 ' set all PORTA as output
LEDLength var PORTB.4
LEDSave var PORTB.3
LEDIncrease var PORTB.7
LEDDecrease var PORTA.3
Delay var word
Loop var word
PB var byte
Increase con 1
Decrease con 2
Both con 3
data @0,5,$DC ' store initial 1.5 sec
PORTB=0 '
' Clear all LEDs
PORTA=0 '
DelayLoop:
read 0,delay.highbyte ' Read delay
read 1,delay.lowbyte ' from EEPROM
ledlength=1 ' Enable Length LED
for loop=0 to delay ' Do the delay and do PushButton tests
pause 1
pb=(PORTB>>5)& 3 ' keep only PORTB.5 and PORTB.6 bits
if pb then ' If there's at least one push button press
select case Pb ' choose according thing to do
case increase
if delay<=60000 then
delay=delay+500
ledincrease=1
endif
case decrease
if delay>=500 then
delay=delay-500
leddecrease=1
endif
case both
ledsave=1
write 0, delay.highbyte
write 1, delay.lowbyte
end select
pause 100 ' kinda auto repeat delay... can be higher/lower
ledincrease=0 ' Clear all pushButtons
leddecrease=0 ' related
ledsave =0 ' LEDs
endif
next
ledlength=0 ' confirm delay is finished
pause 500 ' wait a little bit
goto DelayLoop ' redo the delay and blah blah
Bookmarks