Device = 18F2420
Clock = 20
//Config OSC = INTIO67 delete this as I am using crystal oscilliator
//Include "InternalOscillator.bas "
Include "shift.bas"
Include "utils.bas"
Include "convert.bas"
//Include "InternalOscillator.bas "
Dim SDI As PORTC.4
Dim CLK As PORTC.5
Dim LE As PORTC.3
Dim RED_OE As PORTC.0
Dim GREEN_OE As PORTC.1
Dim DataPin As SDI
Dim ClockPin As CLK
Dim ResetPin_R As RED_OE
Dim ResetPin_G As GREEN_OE
Dim index As Byte
Dim X As Byte
Dim I As Byte
{
Dim row0 As PORTB.0
Dim row1 As PORTB.6
Dim row2 As PORTB.1
Dim row3 As PORTB.2
Dim row4 As PORTB.3
Dim row5 As PORTB.4
Dim row6 As PORTB.5
Dim led As PORTA.0
}
Dim count As Word
Dim colum_buffer(5) As Byte
Dim Z As Byte
dim s1 as porta.3
dim s2 as porta.4
Const Data(15)As Byte = (%00010001, %00001010 ,%00000100, %00010001, %00001010, %00000100,
%00010001, %000001010 ,%00000100, %000010001,%00001010, %00000100, %000010001,%00001010, %00000100)
Const Rows(15) As Byte =(%00000001, %000000010 ,%00000100, %000000010, %00000100, %00001000,
%00000100 ,%000001000 ,%00010000 ,%00001000,%00010000 ,%00100000, %00010000 ,%00100000, %01000000)
Const L_TRows(15) As Byte =( %01000000,%00100000,%00010000,%00100000,%000010000, %00001000,
%00010000, %00001000, %00000100 ,%00001000, %000000100,%00000010,%00000100, %000000010,%00000001)
Const Ride_Data(15)As Byte = (%00011111, %00000100 ,%00011111, %00000100, %00011111, %00000100,
%00011111, %00000100 ,%00011111, %00000100,%00011111, %00000100, %00011111,%00000100, %00011111)
Const R_Rows(15) As Byte =(%00001000, %011111110 ,%00001000, %011111110, %00001000, %01111110,
%00001000 ,%011111110 ,%00001000 ,%01111110,%00001000 ,%01111110, %00001000 ,%01111110, %00001000)
Sub RIDE()
For index = 0 To Bound (Ride_Data)
DelayMS(100)//10 500us for constant on
X = (Ride_Data(index))
LE = 0
ResetPin_R = 1 // disable OE RED
ResetPin_G = 1 // disable OE Green
Shift.Out(MSB_FIRST, X ,8)
LE = 1 //Latch data
PORTB =R_Rows(Z)
DelayUS(200) //20 us
ResetPin_G = 0 // output LOW = ON HIGH = OFF
ResetPin_R = 1
LE = 0
Z = Z+1
Next
End Sub
Sub RIGHT()
For index = 0 To Bound (Data)
DelayMS(10)//10 500us for constant on
X = (Data(index))
LE = 0
ResetPin_R = 1 // disable OE RED
ResetPin_G = 1 // disable OE Green
Shift.Out(MSB_FIRST, X ,8)
LE = 1 //Latch data
PORTB =Rows(Z)
DelayUS(20) //20 us
ResetPin_R = 0 // output LOW = ON HIGH = OFF
ResetPin_g = 1
LE = 0
Z = Z+1
Next
End Sub
Sub LEFT()
For index = 0 To Bound (Data)
DelayMS(10)//10 500us for constant on
X = (Data(index))
LE = 0 // move to top
ResetPin_R = 1 // disable OE RED
ResetPin_G = 1
Shift.Out(MSB_FIRST, X ,8)
LE = 1 //Latch data
PORTB =L_TRows(Z) // display byte on matrix
DelayUS(200) //10 1 us for constant on
ResetPin_R = 0 // output disable
ResetPin_g = 1
Z = Z+1
Next
End Sub
Shift.SetOutput(DataPin)
Shift.SetClock(ClockPin)
ADCON1 = $07
Output(ResetPin_R)
Output(ResetPin_G)
Output (LE)
count = 0
// start of main
TRISB = %00000000
s1 = 1
s2 = 1
// start of main
SetAllDigital
While true
Z = 0
count = 0
index = 0
If s1 = 0 Then // sw 1 closed
DelayMS(3)//debounce
Repeat
LEFT
DelayMS(200)
//ResetPin_G = 1 // output LOW = ON HIGH = OFF this shuts off trailing byte in shifter reg.
Until count = 10 // total of 11 arrows
End If
If s2 = 0 Then
DelayMS(3)
Repeat
RIGHT
Inc(count)
DelayMS(200)
// ResetPin_G = 1 // output LOW = ON HIGH = OFF this shuts off trailing byte in shifter reg.
Until count = 10 // total of 11 arrows
End If
If s1 = 1 And s2 = 1
Then
RIDE
DelayMS(200)
// ResetPin_G = 1 // output LOW = ON HIGH = OFF this shuts off trailing byte in shifter reg.
End If
Wend
End