-
arrays LEDs Switches
Hello Folks,
I am trying to control these tiny LEDs with my switches, right now 8 for 8 but it is going to be 25 for 25 in the end so this is just a proto to figure out whats going on. MY code is working in a sense, I just happen to get high all of my LEDs like I wanted and made some low according to me, but when I try to connect them to my switches which are lying on the PORTB, I just could control the PINO of the PORTB, I am pasting my code below, and looking for your answers.
Thanks in advance
ilteris.
Code:
define OSC 4
start:
TRISC = 0
TRISB = 1
PORTC = 255
PORTB = 255
i var BYTE
j var BYTE
myByte var BYTE
delayTime var Byte
mySwitch var byte
delayTime = 100
pause delayTime
main:
for j=0 to 7
if PORTB.0(j) = 1 then
mybyte.0(j) = 0
PORTC = myByte
else
mybyte.0(j) = 1
PORTC = myByte
endif
next
for i=0 to 7
if i = 4 then
myByte.0(i) = 0
PORTC = myByte
else
myByte.0(i) = 1
PORTC = myByte
endif
next
goto main
-
You are only setting Bit 0 of PortB to input... Try this...
Code:
TRISB=%11111111
TRISC=%00000000
Option_Reg.7=0
Mybyte var Byte
Loop:
MyByte=PortB
PortC=Mybyte
Pause 100
Goto Loop
End
-
hello Melanie,
Thanks for the quick feedback although I am not sure I understood it correctly, I try adding this snippet to my with no dice, also open a new file and tried in that too but it is still no go, can you elaborate it quite a bit, also I couldnt find any documents on option_reg, can you tell me what is it?
Thank you so much for your patience.
ilteris.