This article is interesting reading. Have seen similar.
I have used the portb.bits(x) and yes it can get confusing but it is a valuable coding tool..
So far I give Jon a B+ for this informational article.
To add more confusion but helpful sometimes is portb(x),bits(y)
DIM Scroll_Speed AS INTEGER
DIM x AS BYTE
DIM y AS BYTE
SetAllDigital // Make all Pins digital I/O's
TRISC = %00000000 // Make PORTD all outputs
TRISB = %00000000
Scroll_Speed = 60
y = 0
WHILE true
FOR x = 0 TO 7
portc = %00000000
portc = A_data(x + y) //CONST array data Portc C is Anodes
portb = Cathodes_Data(x) // Cathodes on PortB
DELAYMS(1)
portc = %00000000
DELAYuS(100)
NEXT
IF y +x <210 THEN // number of byte data in CONST arrays
DELAYMS(Scroll_Speed)
y = y + 1 // next A_Data byte data
ELSE
y = 0
END IF
WEND
DEVICE = 18F2420
CLOCK = 8
INCLUDE "convert.bas"
INCLUDE "InternalOscillator.bas"
INCLUDE "Utils.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
DIM led(7) AS BYTE
// variable declaration
DIM x AS BYTE
DIM y AS BYTE
DIM index AS BYTE
CONST Anodes_data(8)AS BYTE = (%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000)
CONST Cathodes_Data(8) AS BYTE = (%11111110,%11111101,%11111011,%11110111,%11101111,%11011111,%10111111,%01111111)
// Start Of Program
SetAllDigital // Make all Pins digital I/O's
TRISC = %00000000 // Make PORTC all outputs
TRISB = %00000000 // Make PORTB all outputs
// Main Loop
WHILE True()
FOR x = 0 TO 7
FOR y = 0 TO 7
portc=Anodes_data(y)
portb=Cathodes_Data(x)
DELAYMS(200)
portc = %00000000
DELAYMS(200)
NEXT
NEXT
WEND
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?