MrDEB
Well-Known Member
been hacking away at this trying to figure out why I keep getting an extra led dot on. Numbers 12 - 2 work except # 5, 3, and 1 routine have the extra led on or ghosting.
been running only routine one to try and decipher how to eliminate the ghosting.
any suggestions. NOTE checked for shorts etc. even used a different test circuit, same results.
been running only routine one to try and decipher how to eliminate the ghosting.
any suggestions. NOTE checked for shorts etc. even used a different test circuit, same results.
Code:
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2016 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 11/19/2016 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
//xxxxxxxxxxxxxxxxxxxxxxxxxx
Device = 18F43k20 ' Tell the compiler what chip we are using
Clock = 8 ' Tell the compiler what we will be setting the clock to (Mhz)
//CONFIG MCLRE = OFF
Config fOSC = INTIO67 ' Internal oscillator, IO on pins 6 and 7
Include "SetDigitalIO.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
Include "utils.bas"
Include "convert.bas" //xxxxx
Dim y As Byte
Dim x As Byte
Dim led As PORTA.0
Dim index As Word
Dim Switch As PORTA.3
Dim led1a As PORTD.3
Dim led1c As PORTB.3
// Sub Routines
// Arrays
// CONST Cathodes_Data(9)AS BYTE = (%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,%00000000)
Const Cathodes_Data(8)As Byte = (%01111111, ' KEEP THESE AS THEY DON"T CHANGE PER LETTER
%10111111, ' this is for scanning the rows
%11011111, //cathodes
%11101111,
%11110111,
%11111011,
%11111101,
%11111110)
Const Cat_Data(8)As Byte = (%11111111, ' KEEP THESE AS THEY DON"T CHANGE PER LETTER
%11111111, ' this is for scanning the rows
%11111111, //cathodes
%11101111,
%11111111,
%11111111,
%11111111,
%11111111)
Const One(8)As Byte = (%00000000,
%00000000,
%00000000, //these are the anode,
%00010000,
%00000000,
%00000000,
%00000000,
%00000000)
' number 2
Const Two(8)As Byte = (%10000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000010,
%00000000)
Const Three(8) As Byte =(%10000000,
%00000000,
%00000000,
%00010000,
%00000000,
%00000000,
%00000010,
%00000000)
Const Four(8) As Byte =(%10000001,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000,
%10000001,
%00000000)
{
(%00000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000,
%00000000)
}
Const Five(8) As Byte = (%10000010,
%00000000,
%00000000,
%00010000,
%00000000,
%00000000,
%00000000,
%10000010)
Const Six(8) As Byte = (%10000010,
%00000000,
%00000000,
%10000010,
%00000000,
%00000000,
%10000010,
%00000000)
Const Seven(8) As Byte =(%10010010,
%00000000,
%00000000,
%10000010,
%00000000,
%00000000,
%10000010,
%00000000)
Const Eight(8) As Byte =(%10010010,
%00000000,
%00000000,
%10010010,
%00000000,
%00000000,
%10000010,
%00000000)
Const Nine(8) As Byte= (%10010010,
%00000000,
%00000000,
%10010010,
%00000000,
%00000000,
%10010010,
%00000000)
Const Ten(8) As Byte= (%10010010,
%00000000,
%10010010,
%00000000,
%10000010,
%00000000,
%10000010,
%00000000)
Const Eleven(8) As Byte=(%10010010,
%00000000,
%10010010,
%00000000,
%10010010,
%00000000,
%10000010,
%00000000)
Const Tweleve(8)As Byte=(%10010010,
%00000000,
%10010010,
%00000000,
%10010010,
%00000000,
%10010010,
%000000000)
// Start Of Program
'portd = 0
'portb = 1
SetAllDigital // Make all Pins digital I/O's
TRISB = %00000000 // Make PORTB all outputs // Make PORTD all outputs
TRISC = %00000000 // Make PORTC all outputs
TRISA = %00000000
TRISD = %00000000
x = 0
y = 0
Switch = 1
SetAllDigital
Input (Switch)
Switch = 1
PORTB = %11111111//Cathodes_Data(x) rows top to bottom
PORTD = %00000000//A_data(x) colums 8 (L-R
// Main Loop
While True()
{
//12
repeat
For x = 0 To 7
PORTD = Tweleve(x)// colums 8 (L-R the X is the scan
PORTB = Cathodes_Data(x) //rows top to bottom
DelayuS(200) //keeps the led enabled until a button pressed
Next
Until Switch=0
DelayMS(30) //debounce
//11
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Eleven(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until Switch=0
DelayMS(30)
//10
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Ten(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until
Switch=0
DelayMS(30)
//9
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Nine(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until Switch=0
DelayMS(30)
//8
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Eight(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until Switch=0
DelayMS(30)
//7
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Seven(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until Switch=0
DelayMS(30)
//SIX
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Six(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until Switch=0
DelayMS(30) //debounce
//5
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Five(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until Switch=0
DelayMS(30)
//FOUR
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Four(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until Switch=0
DelayMS(30)
//3
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Three(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until Switch=0
DelayMS(30)
//2
Repeat
For x = 0 To 7
PORTB = Cathodes_Data(x) //rows top to bottom
PORTD = Two(x)// colums 8 (L-R the X is the scan
DelayUS(200)
Next
Until Switch=0
DelayMS(30)
}
//1
Repeat
'For x = 0 To 7
PORTB = %11101111 //rows top to bottom
PORTD = %00010000 //colums 8 (L-R the X is the scan
DelayUS(200)
PORTB=%11111111
DelayUS(1000)
'Next
Until Switch=0
DelayMS(30)
'Next
'Next
//delayms(2000)INSERT A BUTTON PRESS HERE TO DECREASE THE NUMBER
// y = y + 1
Wend // Loop back to the while loop as long as we havent finished.