The large digit clock used 20ma X 4 displays = 80ma thus he used 80 ma to supply the display which equates to 20ma each display.
Just as I suspected, Tried the 500usON and 100USoff. VERY DIM and only show 12.7ma draw. I need to revamp my resistors for higher current.
Its even worse w/ the Green LEDs.
Will get back to you with a video AFTER I get new resistors etc.
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 10/16/2012 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 9/19/2012 *
* Version : 1.0 *
* Notes :brads suggestion 9/19/2012 *
* : new code revised board 10/15/2012 *
*****************************************************************************
}
Device = 18F4520
Clock = 8
Config MCLRE = Off
'*********************************************************************
'Includes
Include "InternalOscillator.bas"
Include "utils.bas"
Include "convert.bas"
'*********************************************************************
'Dimension Statements (variable and constants
//Dim row As PORTD // row 0 to 6
Dim row_buffer(7) As Byte
Dim count As Word
Dim x As Byte
Dim y As Word
dim z as word
//
Const Red_Data(7) As Byte = (%0010001, %00001010, %00000100 ,%00010001, %00001010,%00000100, %00010001)// 5 colums left to right
Const Cross_Data(7) As Byte = (%00011111, %00000011, %00000111 ,%00011111, %00111111, %01111111, %01111111)
Const R_ows(8) As Byte = (%00000001, %00000010, %000000100 ,%00001000, %00010000, %00100000, %01000000,%00111110)// 7 rows top to bottom
Const Green_Data(8) As Byte = (%00000000,%00010001, %00001010, %000000100 ,%00001010, %00010001, %00000000, %00011111)// 7 rows top to bottom
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// STOP ROUTINE
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
sub test()
y=10
z =12
y=3
z = 5
For x = 0 To 14
PORTa = Green_Data(7) // all on
PORTD = R_ows(3) //row 4
DelayMS(y)
PORTa = Green_Data(3) // middle segment
PORTD = R_ows(7)
DelayMS(z)
// DelayMS(y)
// PORTD.bits(x)=0
next
x=0
end sub
sub STOP()
y=7
z = 5
For x = 0 To 5
PORTa = Green_Data(1)
PORTD = R_ows(1)
DelayMS(y)
PORTa = Green_Data(2)
PORTD = R_ows(2)
DelayMS(y)
PORTa = Green_Data(3)
PORTD = R_ows(3)
DelayMS(y)
PORTa = Green_Data(2)
PORTD = R_ows(4)
DelayMS(y)
PORTa = Green_Data(1)
PORTD = R_ows(5)
delayms(y)
next
for x = 0 to 5
//CROSS
PORTa = Green_Data(7) // all on
PORTD = R_ows(3) //row 4
DelayMS(y)
PORTa = Green_Data(3) // middle segment
PORTD = R_ows(7)
DelayMS(y)
next
end sub
Sub RIGHT()
y=5
z = 30
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// first arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(0)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(1)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(2)
DelayMS(y)
next
delayms(z)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// second arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(1)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(2)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(3)
DelayMS(y)
next
delayms(z)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// third arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(2)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(3)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(4)
DelayMS(y)
next
delayms(z)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//fourth arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(3)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(4)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(5)
DelayMS(y)
next
delayms(z)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// fifth arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(4)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(5)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(6)
DelayMS(y)
Next
delayms(z)
End Sub
//SUB ENDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Sub LEFT()
y=5
z = 30
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// first arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(6)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(5)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(4)
DelayMS(y)
next
delayms(z)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// second arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(5)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(4)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(3)
DelayMS(y)
next
delayms(z)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// third arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(4)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(3)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(2)
DelayMS(y)
next
delayms(z)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//fourth arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(3)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(2)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(1)
DelayMS(y)
next
delayms(z)
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// fifth arrow
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For x = 0 To 14
PORTC = Red_Data(0)
PORTD = R_ows(2)
DelayMS(y)
PORTC = Red_Data(1)
PORTD = R_ows(1)
DelayMS(y)
PORTC = Red_Data(2)
PORTD = R_ows(0)
DelayMS(y)
Next
delayms(z)
End Sub
//SUB ENDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// set ports as outputs
TRISA = %00000000
TRISB = %00000000
TRISC = %00000000
TRISD = %00000000
count = 0
SetAllDigital
//row = 0
PORTB = 0
PORTC = 0
PORTA = 0
PORTD=0
While true
For count =0 To 5 // run 21 times
// load()
{
RIGHT() // sub call
DelayMS(50)
Next
for count = 0 to 5
LEFT()
delayms(50)
next
}
//for count = 0 to 5
//STOP()
//delayms(50)
//next
// for count = 0 to 5
STOP()
next
Wend
It's perfectly ok it have more than one LED illuminated at the same time if and only if each is powered via its own resistor.[/i]. This is the entire idea behind multiplexed LED displays. Look at the Tetris article or the seven-segment article you posted.
Sub STOP()
y=15
z = 20
For x = 0 To 5
PORTA = Green_Data(1)
PORTD = R_ows(1)
DelaymS(y)
PORTA = Green_Data(2)
PORTD = R_ows(2)
DelaymS(y)
PORTA = Green_Data(3)
PORTD = R_ows(3)
DelaymS(y)
PORTA = Green_Data(2)
PORTD = R_ows(4)
DelaymS(y)
PORTA = Green_Data(1)
PORTD = R_ows(5)
DelaymS(y)
Next
//cross bar
//CROSS
PORTA = Green_Data(7) // all on
PORTD = R_ows(3)
// long verticle
DelaymS(75) // This routine scans the rows from row 2 to 5
For s = 1 To 5 //Const R_ows(8) As Byte = (%00000001, %00000010,
PORTA = Green_Data(3) // %000000100 ,%00001000, %00010000, %00100000, %01000000,%00111110)
PORTD = R_ows(s) // works pretty well and the current draw is acceptal at 16ma ( a green LED = 17.4ma by itself
delayms(z)
Next
End Sub
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?