MrDEB
Well-Known Member
trying to implement a bi color led matrix but my code won't switch from GREEN to RED.
portd = GREEN colums while portC = RED
using a common cathode (Knigbright TBC40-11EGWA)
All the leds work but the 7 rows (anodes) are using portA.0-A.3 & portB.0 - B.3
tried designating different colum dsignations for the RED and GREEN but to no avail.
Presently just working on the RIGHT sub
must be a better way to mix different port output bits
portd = GREEN colums while portC = RED
using a common cathode (Knigbright TBC40-11EGWA)
All the leds work but the 7 rows (anodes) are using portA.0-A.3 & portB.0 - B.3
tried designating different colum dsignations for the RED and GREEN but to no avail.
Presently just working on the RIGHT sub
must be a better way to mix different port output bits
Code:
device and clock
Device = 18f4520
Clock = 20 // 20mhz clock
Include "utils.bas"
'*********************************************************************
'Dimension Statements (variable and constants
// row 3 row 2& 4 rows 1 & 5 row 1,2,4,5 all rows stp
Const ColG(7) As Byte = (%00000100, %00001010, %00010001, %00011011, %00100001, %11111111, %00011100 ) // Active RowPort pins for each section of the arrow
Const ColR(7) As Byte = (%00000100, %00001010, %00010001, %00011011, %00100001, %11111111, %00011100 ) // Active RowPort pins for each section of the arrow
// 7 colums from right to left
Const Rows(7) As Byte = (%00000001, %00000010, %00000100, %00001000, %00010000, %00100000, %01100000) // Active ColPort pin for each section of the arrow
// col3 col4 col5
Const stp(8) As Byte = (%00000000, %00001110, %00010001,%00010001,%00010001,%00010001,%00001110, %00000000)
Dim row As PORTA
Dim row_tris As TRISA //trisx to make all outputs
Dim rowB As PORTB
Dim rowB_tris As TRISB
Dim colmC As PORTC
Dim colmC_tris As TRISC //red
Dim colmD As PORTD
Dim colmD_tris As TRISD //green
Dim count As Word
Dim i As Byte
//DIM x AS BYTE
//dim col as byte
'*********************************************************************
'Subroutines and functions
//RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
Sub right()
For i = 0 To 6 // this is to loop it long enough
// to see it
colmc=ColR(3)
row = Rows(1)
// rowB=Rows(0)
DelayMS(3000)
Next
//colmD=Col(i)
//row = Rows(1)
//DelayMS(1000)
// colmD=Col(i)
//row = Rows(2)
//DelayMS(1000)
End Sub
//RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
//LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
Sub left()
For i = 7 To 0 Step -1 // this is to loop it long enough
// to see it
colmd=Colg(0)
row = Rows(1)
DelayMS(70)
Next
colmD=ColG(1)
row = Rows(1)
DelayMS(70)
//next
colmD=ColG(2)
row = Rows(4)
DelayMS(70)
End Sub
//LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Sub stop()
For i = 0 To 7 // this is to loop it long enough
// to see it
colmD= %01111110 // L/R sides of stop sign %01100010
row = %00011110
DelayMS(10)
colmD= %00011100 //TOP BOTTOM of sign
row = %01100001
DelayMS(10)
//NEXT
// FOR i = 0 TO 10
colmD= %000100010
row = %0000100001
DelayMS(10)
colmD= %00010100
row = %00001010
DelayMS(10)
colmD= %00001000
row = %00000100
DelayMS(100)
Next
// row = Rows(4) //%00110001
// colm=stp(1)
// row = Rows(6)
//DELAYMS(1000)
// NEXT
End Sub
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'Notice Function name, code steps, function end. Indenting shows what's contained 'inside the function or subroutine
'Note: If any subroutine calls another subroutine or function, the called sub or
' function must be placed first in the listing
'*********************************************************************
'Program initialization - only gets done once. Define initial variable conditions and etc.
colmD= 0
row = 0
row_tris = 0
colmD_tris = 0
count = 0
//x=100
'Note: The above happens only once when the program initializes.
'*********************************************************************
'Main program loop. This continues forever
While true
setalldigital
For count = 0 To 20 // this is to loop it long enough
left()
DelayMS(2000)
//stop
Next
Wend
{
FOR count = 0 TO 20
left
DELAYMS(100)
NEXT
FOR count = 0 TO 20
stop
DELAYMS(100)
NEXT
WEND
}
'Note: the above goes on forever. This is the main program and all action
' is directed from within this loop
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx