Hi, Pdegior
I saw something in the manual ....$ 4.17.14 ...
Have a look to it ...
Alain
Hi, Pdegior
I saw something in the manual ....$ 4.17.14 ...
Have a look to it ...
Alain
And you're using a BYTE sized variable to do it.Code:TRISA=255 ' Set all PORTA pins to Input dip var byte Start: dip=PORTA select case dip case 0 ' ' Code for PORTA=0 ' case 1 ' ' Code for PORTA=1 ' case 2 ' ' Code for PORTA=2 ' end select goto start
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi Pdegior. I tested this program with only part of PORTA and it works. Hope this helps.
'CODE COMPILED FOR 16F818
OSCCON = $60 'set int osc to 4mhz
adcon1 = 7 ' set inputs to digital
TRISA = %11111111 'ALL PORTA INPUTS
TRISB = %00000000 'ALL PORTB OUTPUTS
PORTB = 0 'ALL OUTPUTS LOW
@ DEVICE MCLR_ON, INTRC_OSC, WDT_ON, LVP_OFF, BOD_ON, PWRT_ON, PROTECT_ON
DIP VAR BYTE
START:
PORTB = 0 'off all leds
LET DIP = 0 'clear the variable DIP
LET DIP.BIT0 = 0
IF PORTA.0 = 1 Then LET DIP.BIT0 = 1 'dip bits are 0 unless PORTA bit is high
LET DIP.BIT1 = 0
IF PORTA.1 = 1 Then LET DIP.BIT1 = 1
LET DIP.BIT2 = 0
IF PORTA.2 = 1 Then LET DIP.BIT2 = 1
LET DIP.BIT3 = 0
IF PORTA.3 = 1 Then LET DIP.BIT3 = 1
IF DIP = 0 Then High PORTB.0 'light corresponding LED
IF DIP = 1 Then High PORTB.1
IF DIP = 2 Then High PORTB.2
IF DIP = 3 Then High PORTB.3
Pause 1000 'wait a second
PORTB = 0 'off led
GoTo START 'do it again
Thanks,
that seems to have done it. Still not too sure why the way I had it doesn't work but oh well.
Bookmarks