Alright, so I've been currently into assembly and learning about PICs.
I have bought a HL-K18 board with PIC18F4520 on it, there is also a 8*8 led matris and 4 pin switch.
My goal is to turn on one led in the first column. which I've done.
And then through the switches, if switch 1 is on the led(dot) should move up one bit, if the switch 4 is on the dot(led) should move down in the column one bit at the time.
Also if both switches are off the dot should remain at it's position, and if the dot is at the top and you have switch 1 on, it should just stay at the top. and vice verse if it's at the bottom.
Here's my code
Like I need some help with sending input from switch1 or 4 to portd
and then (shift?) the 0x04 to the right or left depending on what switch is on.
I've attached the Hl-k18 board
I have circled the switch schematic and the led.
View attachment HL-K18原理图.pdf
I have bought a HL-K18 board with PIC18F4520 on it, there is also a 8*8 led matris and 4 pin switch.
My goal is to turn on one led in the first column. which I've done.
And then through the switches, if switch 1 is on the led(dot) should move up one bit, if the switch 4 is on the dot(led) should move down in the column one bit at the time.
Also if both switches are off the dot should remain at it's position, and if the dot is at the top and you have switch 1 on, it should just stay at the top. and vice verse if it's at the bottom.
Here's my code
Code:
MAIN CLRF TRISD ; Set portd as output
BCF TRISA,RA1; Set porta, column 1 as ouput
BSF PORTA,RA1; set porta to 0
BSF TRISB,RB0; input Don't know if rb0 is for switch 1
BSF TRISB,RB5; input Don't know if rb5 is for switch 4
LOOP
MOVF PORTB,W
NOP ; No Operation so it can read the portb before sending to portd
MOVLW 0x04 ; Have the first dot at 0x04.
MOVWF PORTD
GOTO LOOP
end
and then (shift?) the 0x04 to the right or left depending on what switch is on.
I've attached the Hl-k18 board
I have circled the switch schematic and the led.
View attachment HL-K18原理图.pdf
Attachments
-
72.1 KB Views: 44