mc14489 with 4 digit 7 segments parts of Bruce Reynolds code
Markdahplumber
Posts: 7
Hello
I like working with this display and can't thank everyone enough who loves to teach how code or projects are done.
When I use parts of Bruce R 's code and try to make a little code of my own with it , sometimes it works and sometimes it doesn't. I am using the stamp 2 nothing great compared to sx - p etc but its just perfect for my needs and since i have 3 of them, i figure well if i can get one to work anyone can! I have a question tho ( one of million) when i code my stamp like in A example below it works awsome and when I could it in B example it doesn't show the display and since I have to pound the books like 100 times in my head to get anywhere with EASY basic code I was wondering why that is or did I invent the impossible?
well take care
mark
A example
' {$STAMP BS2}
' {$PBASIC 2.5}
' example A
EN PIN 2 ' Connect to SLED4C enable pin #5
CLK PIN 0 ' Connect to SLED4C clock pin #4
DOUT PIN 1 ' Connect to SLED4C data pin #3
motor PIN 15 ' this pin is connected to a led for similator a motor switch
ele PIN 14 ' this pin is connected to a led for sim heater element
warn PIN 13 ' this pin is connected to a led for sim incase the BS2 is on fire
'Variables
'
X VAR Word ' GP var bruce code
Y VAR Byte ' GP var
b VAR Byte ' Bank #1 controls the colon ":"
D2 VAR Byte ' SLED4C bank #2 digit (right)
D3 VAR Byte ' SLED4C bank #3
D4 VAR Byte ' SLED4C bank #4
D5 VAR Byte ' SLED4C bank #5 digit (left)
CFG VAR Byte ' Holds display configuration value
'
OUTPUT 15 ' my code
OUTPUT 14 ' << it wont work unless make these pins outputs
OUTPUT 13
'Initialization
'
DIRL = 255 'bruce code maybe someday i will figure it out
CFGN CON %11000001
START:
b = 0
GOTO FLASH
Help: ' Display H.E.L.P. while toggling brightness from 100% to 50%
CFG = %11101111 ' Digits 5,3,2,1 special decode, 4 HEX decode
GOSUB Config ' Configure display
' Now write H.E.L.P. to display blinking 50% to 100% brightness
Y = %00000111 ' Setup bit 3 for toggling display brightness
FOR X = 0 TO 4 ' and all DP's ON
EN = 0 ' Enable data input
Y.BIT3 = Y.BIT3 ^ 1' Flip Y.bit3 by XOR-ing with 1 [ 0=DIM, 1=BRIGHT ]
' Y = brightness & DP's 5 4 3 2 :=OFF
SHIFTOUT DOUT, CLK, MSBFIRST, [Y\4, $2\4, $E\4, $5\4, $8\4, $0\4]
EN = 1 ' Transfer data into display registers
PAUSE 40
NEXT
GOTO start
Config:
EN = 0 ' Enable data input
SHIFTOUT DOUT, CLK, MSBFIRST, [CFG] ' Write to display config register
EN = 1
PAUSE 1 ' Transfer data into display registers
RETURN
END
'
' my code and IT WORKS!!!
FLASH: ' this code is to just flash leds wasting power but kinda cool
b = b + 1
motor = 1
ele = 1
warn = 1
PAUSE 20
warn = 0
ele = 0
motor = 0
PAUSE 150
IF b = 2 THEN help
GOTO FLASH ' simple? YES understandable? NO
'
_______________________________________________________________________________________________________________
B example this will make the display not light up at all
' {$STAMP BS2}
' {$PBASIC 2.5}
' example A
EN PIN 2 ' Connect to SLED4C enable pin #5
CLK PIN 0 ' Connect to SLED4C clock pin #4
DOUT PIN 1 ' Connect to SLED4C data pin #3
motor PIN 15 ' this pin is connected to a led for similator a motor switch
ele PIN 14 ' this pin is connected to a led for sim heater element
warn PIN 13 ' this pin is connected to a led for sim incase the BS2 is on fire
'Variables
'
X VAR Word ' GP var bruce code
Y VAR Byte ' GP var
b VAR Byte ' Bank #1 controls the colon ":"
D2 VAR Byte ' SLED4C bank #2 digit (right)
D3 VAR Byte ' SLED4C bank #3
D4 VAR Byte ' SLED4C bank #4
D5 VAR Byte ' SLED4C bank #5 digit (left)
CFG VAR Byte ' Holds display configuration value
'
OUTPUT 15 ' my code
OUTPUT 14 ' << it wont work unless make these pins outputs
OUTPUT 13
'Initialization
'
DIRL = 255 'bruce code maybe someday i will figure it out
CFGN CON %11000001
START:
dont need B= 0 because of the loop for this code
GOTO FLASH
Help: ' Display H.E.L.P. while toggling brightness from 100% to 50%
CFG = %11101111 ' Digits 5,3,2,1 special decode, 4 HEX decode
GOSUB Config ' Configure display
' Now write H.E.L.P. to display blinking 50% to 100% brightness
Y = %00000111 ' Setup bit 3 for toggling display brightness
FOR X = 0 TO 4 ' and all DP's ON
EN = 0 ' Enable data input
Y.BIT3 = Y.BIT3 ^ 1' Flip Y.bit3 by XOR-ing with 1 [ 0=DIM, 1=BRIGHT ]
' Y = brightness & DP's 5 4 3 2 :=OFF
SHIFTOUT DOUT, CLK, MSBFIRST, [Y\4, $2\4, $E\4, $5\4, $8\4, $0\4]
EN = 1 ' Transfer data into display registers
PAUSE 40
NEXT
GOTO start
Config:
EN = 0 ' Enable data input
SHIFTOUT DOUT, CLK, MSBFIRST, [CFG] ' Write to display config register
EN = 1
PAUSE 1 ' Transfer data into display registers
RETURN
END
'
' my code and it wont light the led display to show help it just stays dead
FLASH: ' this code is to just flash leds wasting power but kinda cool
DO UNTIL 2 < this code is changed from b= b + 1
motor = 1
ele = 1
warn = 1
PAUSE 20
warn = 0
ele = 0
motor = 0
PAUSE 150
LOOP and changed the if b = 2 then help
GOTO help
' simple? YES understandable for me? NO
'
I like working with this display and can't thank everyone enough who loves to teach how code or projects are done.
When I use parts of Bruce R 's code and try to make a little code of my own with it , sometimes it works and sometimes it doesn't. I am using the stamp 2 nothing great compared to sx - p etc but its just perfect for my needs and since i have 3 of them, i figure well if i can get one to work anyone can! I have a question tho ( one of million) when i code my stamp like in A example below it works awsome and when I could it in B example it doesn't show the display and since I have to pound the books like 100 times in my head to get anywhere with EASY basic code I was wondering why that is or did I invent the impossible?
well take care
mark
A example
' {$STAMP BS2}
' {$PBASIC 2.5}
' example A
EN PIN 2 ' Connect to SLED4C enable pin #5
CLK PIN 0 ' Connect to SLED4C clock pin #4
DOUT PIN 1 ' Connect to SLED4C data pin #3
motor PIN 15 ' this pin is connected to a led for similator a motor switch
ele PIN 14 ' this pin is connected to a led for sim heater element
warn PIN 13 ' this pin is connected to a led for sim incase the BS2 is on fire
'Variables
'
X VAR Word ' GP var bruce code
Y VAR Byte ' GP var
b VAR Byte ' Bank #1 controls the colon ":"
D2 VAR Byte ' SLED4C bank #2 digit (right)
D3 VAR Byte ' SLED4C bank #3
D4 VAR Byte ' SLED4C bank #4
D5 VAR Byte ' SLED4C bank #5 digit (left)
CFG VAR Byte ' Holds display configuration value
'
OUTPUT 15 ' my code
OUTPUT 14 ' << it wont work unless make these pins outputs
OUTPUT 13
'Initialization
'
DIRL = 255 'bruce code maybe someday i will figure it out
CFGN CON %11000001
START:
b = 0
GOTO FLASH
Help: ' Display H.E.L.P. while toggling brightness from 100% to 50%
CFG = %11101111 ' Digits 5,3,2,1 special decode, 4 HEX decode
GOSUB Config ' Configure display
' Now write H.E.L.P. to display blinking 50% to 100% brightness
Y = %00000111 ' Setup bit 3 for toggling display brightness
FOR X = 0 TO 4 ' and all DP's ON
EN = 0 ' Enable data input
Y.BIT3 = Y.BIT3 ^ 1' Flip Y.bit3 by XOR-ing with 1 [ 0=DIM, 1=BRIGHT ]
' Y = brightness & DP's 5 4 3 2 :=OFF
SHIFTOUT DOUT, CLK, MSBFIRST, [Y\4, $2\4, $E\4, $5\4, $8\4, $0\4]
EN = 1 ' Transfer data into display registers
PAUSE 40
NEXT
GOTO start
Config:
EN = 0 ' Enable data input
SHIFTOUT DOUT, CLK, MSBFIRST, [CFG] ' Write to display config register
EN = 1
PAUSE 1 ' Transfer data into display registers
RETURN
END
'
' my code and IT WORKS!!!
FLASH: ' this code is to just flash leds wasting power but kinda cool
b = b + 1
motor = 1
ele = 1
warn = 1
PAUSE 20
warn = 0
ele = 0
motor = 0
PAUSE 150
IF b = 2 THEN help
GOTO FLASH ' simple? YES understandable? NO
'
_______________________________________________________________________________________________________________
B example this will make the display not light up at all
' {$STAMP BS2}
' {$PBASIC 2.5}
' example A
EN PIN 2 ' Connect to SLED4C enable pin #5
CLK PIN 0 ' Connect to SLED4C clock pin #4
DOUT PIN 1 ' Connect to SLED4C data pin #3
motor PIN 15 ' this pin is connected to a led for similator a motor switch
ele PIN 14 ' this pin is connected to a led for sim heater element
warn PIN 13 ' this pin is connected to a led for sim incase the BS2 is on fire
'Variables
'
X VAR Word ' GP var bruce code
Y VAR Byte ' GP var
b VAR Byte ' Bank #1 controls the colon ":"
D2 VAR Byte ' SLED4C bank #2 digit (right)
D3 VAR Byte ' SLED4C bank #3
D4 VAR Byte ' SLED4C bank #4
D5 VAR Byte ' SLED4C bank #5 digit (left)
CFG VAR Byte ' Holds display configuration value
'
OUTPUT 15 ' my code
OUTPUT 14 ' << it wont work unless make these pins outputs
OUTPUT 13
'Initialization
'
DIRL = 255 'bruce code maybe someday i will figure it out
CFGN CON %11000001
START:
dont need B= 0 because of the loop for this code
GOTO FLASH
Help: ' Display H.E.L.P. while toggling brightness from 100% to 50%
CFG = %11101111 ' Digits 5,3,2,1 special decode, 4 HEX decode
GOSUB Config ' Configure display
' Now write H.E.L.P. to display blinking 50% to 100% brightness
Y = %00000111 ' Setup bit 3 for toggling display brightness
FOR X = 0 TO 4 ' and all DP's ON
EN = 0 ' Enable data input
Y.BIT3 = Y.BIT3 ^ 1' Flip Y.bit3 by XOR-ing with 1 [ 0=DIM, 1=BRIGHT ]
' Y = brightness & DP's 5 4 3 2 :=OFF
SHIFTOUT DOUT, CLK, MSBFIRST, [Y\4, $2\4, $E\4, $5\4, $8\4, $0\4]
EN = 1 ' Transfer data into display registers
PAUSE 40
NEXT
GOTO start
Config:
EN = 0 ' Enable data input
SHIFTOUT DOUT, CLK, MSBFIRST, [CFG] ' Write to display config register
EN = 1
PAUSE 1 ' Transfer data into display registers
RETURN
END
'
' my code and it wont light the led display to show help it just stays dead
FLASH: ' this code is to just flash leds wasting power but kinda cool
DO UNTIL 2 < this code is changed from b= b + 1
motor = 1
ele = 1
warn = 1
PAUSE 20
warn = 0
ele = 0
motor = 0
PAUSE 150
LOOP and changed the if b = 2 then help
GOTO help
' simple? YES understandable for me? NO
'
Comments
Believe me, We ALL know that feeling!!!! Wait until you get motors to turn and sensors to work!!! Oh, and Welcome to the Forums!!
SHIFTOUT DOUT, CLK, MSBFIRST [ data? ]
like what does [ ] mean? I know DOUT , CLK, MSBFIRST but do not know the [ ] in the index it shows 4 bit \4 etc but doesn't explain the [ ]
well thanks in advance