{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 11/10/2022 *
* Version : 1.0 *
* Notes : RYDERWOOD SIGN START 11/10/22 *
* : *
*****************************************************************************
}
Device = 18F2221
Clock = 8
Include "intosc.bas"
#option SWORDFISH_SE = true
Include "setdigitalio.bas"//Include "SetDigitalIO.bas"
Include "utils.bas"
Include "Convert.bas"
Include "ledmatrix_4X4"
//12 VOLT LED STRIPS
Dim R As PORTA.0
Dim Y As PORTA.1
Dim D As PORTA.2
Dim E As PORTA.3
Dim R_1 As PORTA.4
Dim W As PORTA.5
Dim o As PORTA.6
Dim D_1 As PORTA.7
Dim nc_1 As PORTB.0 //not used
Dim nc_2 As PORTB.1 //not used
//CAKE SPRINKLES CATHODES USING MOSFETS
Dim Row_1 As PORTB.2
Dim Row_2 As PORTB.3
Dim Row_3 As PORTB.4
Dim Row_4 As PORTB.5
//HEADLIGHT ON TRAIN ENGINE
Dim Head_light As PORTC.7
//CANDLE FLAMES
Dim Flame1 As PORTC.0
Dim Flame2 As PORTC.1
Dim Flame3 As PORTC.2
// SPRINKLES ANODES
Dim RED As PORTC.3
Dim WHITE As PORTC.4
Dim BLUE As PORTC.5
Dim GREEN As PORTC.6
TRISA = 0 //ENABLE OUTPUTS
TRISB = 0
TRISC = 0
while true
NC_1 = 1 //TURN ON MOSFET ON B.0 TESTING 11/11/22
DELAYMS(1000)
TOGGLE (NC_1)
DELAYMS(1000)
RED = 1 //TURN ON LED ON C.3 "CAKE SPRINKLES"
ROW_1 = 1
DELAYMS(500)
TOGGLE(ROW_1)
WEND
while true
NC_1 = 1 //TURN ON MOSFET ON B.0 TESTING 11/11/22
DELAYMS(1000)
NC_1 = 0
DELAYMS(1000)
' RED = 1 //TURN ON LED ON C.3 "CAKE SPRINKLES"
ROW_1 = 1
DELAYMS(1000)
row_1 = 0 //turn off mosfet
delayms(2000)
WEND
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 11/10/2022 *
* Version : 1.0 *
* Notes : RYDERWOOD SIGN START 11/10/22 *
* : *
*****************************************************************************
}
Device = 18F2221
Clock = 8
Include "intosc.bas"
#option DIGITALIO_INIT = true
Include "setdigitalio.bas"
'Include "ledmatrix_4X4"
//12 VOLT LED STRIPS
Dim R As PORTA.0 // channel_1
Dim Y As PORTA.1 // channel_2
Dim D As PORTA.2 // channel_3
Dim E As PORTA.3 // channel_4
Dim R_1 As PORTA.4 // channel_5
Dim W As PORTA.5 // channel_6
Dim O As PORTA.6 // channel_8
Dim D_1 As PORTA.7 // channel_7
Dim NC_1 As PORTB.0 //not used, channel_9
Dim NC_2 As PORTB.1 //not used, channel_10
//CAKE SPRINKLES CATHODES USING MOSFETS
Dim ROW_1 As PORTB.2
Dim ROW_2 As PORTB.3
Dim ROW_3 As PORTB.4
Dim ROW_4 As PORTB.5
//CANDLE FLAMES
Dim FLAME1 As PORTC.0 // flame_1
Dim FLAME2 As PORTC.1 // flame_2
Dim FLAME3 As PORTC.2 // flame_3
// SPRINKLES ANODES
Dim RED As PORTC.3 // colum-1
Dim WHITE As PORTC.4 // colum-2
Dim BLUE As PORTC.5 // colum-3
Dim GREEN As PORTC.6 // colum-4
//HEADLIGHT ON TRAIN ENGINE
Dim HEAD_LIGHT As PORTC.7 // HEAD LIGHT
// before enabling the outputs, init all LAT registers low
LATA = 0
LATB = 0
LATC = 0
TRISA = 0 //ENABLE OUTPUTS
TRISB = 0
TRISC = 0
// "Trying to toggle the rows while C-3 - C.5 (colums) are left HIGH"
// make all column outputs high
RED = 1
WHITE = 1
BLUE = 1
GREEN = 1
while true
NC_1 = 1 //TURN ON MOSFET ON B.0 TESTING 11/11/22
delayms(1000)
NC_1 = 0
delayms(1000)
ROW_1 = 1 //TURN ON LED ON C.3 "CAKE SPRINKLES"
delayms(1000)
ROW_1 = 0 //turn off mosfet
delayms(2000)
wend
// before enabling the outputs, init all LAT registers low
lata = 0
latb = 0
latc = 0
TRISA = 0 //ENABLE OUTPUTS
TRISB = 0
TRISC = 0
red = 1
white = 1
blue = 1
green = 1
row_1 = 0
row_2 = 0
row_3 = 0
while true
r = 1
y = 1
d = 1
e = 1
r_1 = 1
w = 1
O = 1
d_1 = 1
nc_2 = 1
NC_1 = 1 //TURN ON MOSFET ON B.0 TESTING 11/11/22
DELAYMS(1000)
NC_1 = 0
DELAYMS(1000)
' RED = 1 //TURN ON LED ON C.3 "CAKE SPRINKLES"
ROW_1 = 1 //enable the mosfet on row_1 which grounds the cathode through the mosfet
DELAYMS(1000)
Row_1 = 0 //turn off mosfet
delayms(1000)
row_2 =1
delayms(1000)
row_2 = 0
delayms(1000)
ROW_3 = 1 //enable the mosfet on row_1 which grounds the cathode through the mosfet
DELAYMS(1000)
Row_3 = 0 //turn off mosfet
delayms(1000)
row_4 =1
delayms(1000)
row_4 = 0
delayms(1000)
WEND
I don't recall using LAT before., will give it a try.
PORTA = $55
LATA = $55
PORTB.0 = 1
LATB.0 = 1
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2020 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 3/15/2020 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
Module ledmatrix_4X4
//LED MATRIX
Dim RED As PORTC.3
Dim WHITE As PORTC.4
Dim BLUE As PORTC.5
Dim GREEN As PORTC.6
Dim ROW_1 As PORTB.2
Dim ROW_2 As PORTB.3
Dim ROW_3 As PORTB.4
Dim ROW_4 As PORTB.5
// make led pins outputs and turn them all off
Public Sub AllOff()
// ALL ANODES
High(RED)
High(WHITE)
High(BLUE)
High(GREEN)
// High MAKE ALL COLUMS HIGH
// turn off rows ALL CATHodes
Low(ROW_1)
Low(ROW_2)
Low(ROW_3)
Low(ROW_4)
End Sub
// turn on a single led
// led_no = 0 -> nothing on (all off)
// = 1-12 -> turn on specified led
// the routine ignores the comments above and sets the leds "in order"
// so it may not match the (unknown) schematic
// it's long-hand so it can easily be adjusted to match
Public Sub SetLed(led_no As Byte=0)
AllOff()
Select (led_no)
// COL1
Case 1 // 1-4 COLIUMS
RED = 1 //high
ROW_1 = 1 //HIGH TURNS ON MOSFET
Case 2 // row1, col2
WHITE= 1
ROW_1= 1 //HIGH TURNS ON MOSFET
Case 3 // row1, col3
BLUE = 1
ROW_1 = 1 //HIGH TURNS ON MOSFET
Case 4 // ROW 1 COL 4
GREEN = 1
ROW_1 = 1 //HIGH TURNS ON MOSFET
//COL2
Case 5 // 1-4 COLIUMS
RED = 1 //high
ROW_2 = 1 //HIGH TURNS ON MOSFET
Case 6 // row1, col2
WHITE= 1
ROW_2 = 1 //HIGH TURNS ON MOSFET
Case 7 // row1, col3
BLUE = 1
ROW_2 = 1 //HIGH TURNS ON MOSFET
Case 8 // ROW 1 COL 4
GREEN = 1
ROW_2 = 1 //HIGH TURNS ON MOSFET
// COL3
Case 9 // 1-4 COLIUMS
RED = 1 //high
ROW_3 = 1 //HIGH TURNS ON MOSFET
Case 10 // row1, col2
WHITE= 1
ROW_3 = 1 //HIGH TURNS ON MOSFET
Case 11 // row1, col3
BLUE = 1
ROW_3 = 1 //HIGH TURNS ON MOSFET
Case 12 // ROW 1 COL 4
GREEN = 1
ROW_3 = 1 //HIGH TURNS ON MOSFET
//COL4
Case 13 // 1-4 COLIUMS
RED = 1 //high
ROW_4 = 1 //HIGH TURNS ON MOSFET
Case 14 // row1, col2
WHITE= 1
ROW_4 = 1 //HIGH TURNS ON MOSFET
Case 15 // row1, col3
BLUE = 1
ROW_4 = 1 //HIGH TURNS ON MOSFET
Case 16 // ROW 1 COL 4
GREEN = 1
ROW_4 = 1 //HIGH TURNS ON MOSFET
End Select
End Sub
SetLed()
// init
AllOff()
End Module
{
*****************************************************************************
* R W B G COLIUMS
1 2 3 4 ROW_1
5 6 7 8 ROW_2
9 10 11 12 ROW_3
13 14 15 16 ROW_4 *
* : *
*****************************************************************************
}
{
*****************************************************************************
* Name : LEDATRIX4X4_1.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2020 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 11/19/22 *
* Version : 1.0 *
* Notes : edited version for 4 x 4 matrix *
* : *
*****************************************************************************
}
Module ledmatrix_4X4_1
//LED MATRIX
Dim RED As PORTC.3
Dim WHITE As PORTC.4
Dim BLUE As PORTC.5
Dim GREEN As PORTC.6
Dim ROW_4 As PORTB.2
Dim ROW_3 As PORTB.3
Dim ROW_2 As PORTB.4
Dim ROW_1 As PORTB.5
// make led pins outputs and turn them all off
Public Sub AllOff()
// ALL ANODES
High(RED)
High(WHITE)
High(BLUE)
High(GREEN)
// High MAKE ALL COLUMS HIGH
// turn off rows ALL CATHODES
Low(ROW_1)
Low(ROW_2)
Low(ROW_3)
Low(ROW_4)
End Sub
// turn on a single led
// led_no = 0 -> nothing on (all off)
// = 1-12 -> turn on specified led
// the routine ignores the comments above and sets the leds "in order"
// so it may not match the (unknown) schematic
// it's long-hand so it can easily be adjusted to match
Public Sub SetLed(led_no As Byte=0)
AllOff()
Select (led_no)
// COL1
Case 1 // 1-4 COLIUMS
RED = 1 //high
ROW_1 = 0 //LOW ENABLES LED#1
Case 2 // row1, col2
WHITE = 1
ROW_2 = 0 //LOW ENABLES LED#6
Case 3 // row1, col3
BLUE = 1
ROW_3 = 0 //LOW ENABLES LED#11
Case 4 // ROW 1 COL 4
GREEN = 1
ROW_4 = 0 //LOW ENABLES LED#16
//COL2
Case 5 // 1-4 COLIUMS
RED = 1 //high
ROW_1 = 0 //LOW ENABLES LED# 5
Case 6 // row1, col2
WHITE= 1
ROW_2 = 0 //LOW ENABLES LED# 10
Case 7 // row1, col3
BLUE = 1
ROW_3 = 0 //LOW ENABLES LED# 15
Case 8 // ROW 1 COL 4
GREEN = 1
ROW_4 = 0 //LOW ENABLES LED# 4
// COL3
Case 9 // 1-4 COLIUMS
RED = 1 //high
ROW_3 = 0 //LOW ENABLES LED# 9
Case 10 // row1, col2
WHITE= 1
ROW_4 = 0 //LOW ENABLES LED# 14
Case 11 // row1, col3
BLUE = 1
ROW_1 = 0 //LOW ENABLES LED#3
Case 12 // ROW 1 COL 4
GREEN = 1
ROW_2 = 0 //LOW ENABLES LED#8
//COL4
Case 13 // 1-4 COLIUMS
RED = 1 //high
ROW_4 = 0 //LOW ENABLES LED# 13
Case 14 // row1, col2
WHITE= 1
ROW_1 = 0 //LOW ENABLES LED# 10
Case 15 // row1, col3
BLUE = 1
ROW_2 = 0 //LOW ENABLES LED#7
Case 16 // ROW 1 COL 4
GREEN = 1
ROW_3 = 0 //LOW ENABLES LED# 4
End Select
End Sub
SetLed()
// init
AllOff()
End Module
Yes it could be done Mike, but that ain't gonna happen here!Mike.
Edit, I assume Swordfish can easily do interrupts so this could be done automatically. Yes?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?