drieschnoronha
New Member
Dear sirs/madams,
I am a GCSE student. I am using a 18x chip to produce random number generator between 1-49. They way my circuit works is the 8 outputs of the chip connect to two 7 segments.
One 7 seg is a Common Cathode the other a Common Anode.
The flowchart is simple. It goes through the numbers 1-49 and checks whether an input (in my case input 0) is on. If it is, it stops at number is going thorugh it keeps it constantly displayed till button is released.
I wanted to know whether i could use the random command. By this I mean, when an input is activated, a number is displayed for 5 seconds, then another for 5 seconds, then another, and so on till 5 numbers are displayed one after the other. I wanted all the numbers to be different. This code works fine.
Hope I explained it properly.
How it works:
for the common cathode and common anode.
since I am using one 18x and there are 8 outputs, i had to connect and write a weird program.
what happens is when an input is activated, a line repeats itself. the line consists of 1 number from the common cathode and the other from the common anode. then it flashes between the numbers so quickly that it seems that only 1 number is displayed.
For example when the common cathode shows 4 the anode is blank and when the common anode shows 9 the other is blank. since only one 7 seg will ever be on and the other is off, it is possible to run it so quickly that it looks that both are constantly on. Hope you understand.
Your respectfully,
Driesch
Program is here
I am a GCSE student. I am using a 18x chip to produce random number generator between 1-49. They way my circuit works is the 8 outputs of the chip connect to two 7 segments.
One 7 seg is a Common Cathode the other a Common Anode.
The flowchart is simple. It goes through the numbers 1-49 and checks whether an input (in my case input 0) is on. If it is, it stops at number is going thorugh it keeps it constantly displayed till button is released.
I wanted to know whether i could use the random command. By this I mean, when an input is activated, a number is displayed for 5 seconds, then another for 5 seconds, then another, and so on till 5 numbers are displayed one after the other. I wanted all the numbers to be different. This code works fine.
Hope I explained it properly.
How it works:
for the common cathode and common anode.
since I am using one 18x and there are 8 outputs, i had to connect and write a weird program.
what happens is when an input is activated, a line repeats itself. the line consists of 1 number from the common cathode and the other from the common anode. then it flashes between the numbers so quickly that it seems that only 1 number is displayed.
For example when the common cathode shows 4 the anode is blank and when the common anode shows 9 the other is blank. since only one 7 seg will ever be on and the other is off, it is possible to run it so quickly that it looks that both are constantly on. Hope you understand.
Your respectfully,
Driesch
Program is here
Code:
main:
label_50C: if pin1=1 then gosub sub0
label_6: let pins = 252 ' %11111100
let pins = 159 ' %10011111
if pin0=1 then label_6
label_1F: let pins = 252 ' %11111100
let pins = 37 ' %00100101
if pin0=1 then label_1F
label_6A: let pins = 252 ' %11111100
let pins = 13 ' %00001101
if pin0=1 then label_6A
label_F6: let pins = 252 ' %11111100
let pins = 153 ' %10011001
if pin0=1 then label_F6
label_7D: let pins = 252 ' %11111100
let pins = 73 ' %01001001
if pin0=1 then label_7D
label_90: let pins = 252 ' %11111100
let pins = 65 ' %01000001
if pin0=1 then label_90
label_A3: let pins = 252 ' %11111100
let pins = 31 ' %00011111
if pin0=1 then label_A3
label_B6: let pins = 252 ' %11111100
let pins = 1 ' %00000001
if pin0=1 then label_B6
label_DB: let pins = 252 ' %11111100
let pins = 25 ' %00011001
if pin0=1 then label_DB
label_C9: let pins = 96 ' %01100000
let pins = 3 ' %00000011
if pin0=1 then label_C9
label_109: let pins = 96 ' %01100000
let pins = 159 ' %10011111
if pin0=1 then label_109
label_16D: let pins = 96 ' %01100000
let pins = 37 ' %00100101
if pin0=1 then label_16D
label_1D1: let pins = 96 ' %01100000
let pins = 13 ' %00001101
if pin0=1 then label_1D1
label_235: let pins = 96 ' %01100000
let pins = 153 ' %10011001
if pin0=1 then label_235
label_299: let pins = 96 ' %01100000
let pins = 73 ' %01001001
if pin0=1 then label_299
label_2FD: let pins = 96 ' %01100000
let pins = 65 ' %01000001
if pin0=1 then label_2FD
label_361: let pins = 96 ' %01100000
let pins = 31 ' %00011111
if pin0=1 then label_361
label_3C5: let pins = 96 ' %01100000
let pins = 1 ' %00000001
if pin0=1 then label_3C5
label_429: let pins = 96 ' %01100000
let pins = 25 ' %00011001
if pin0=1 then label_429
label_110: let pins = 218 ' %11011010
let pins = 159 ' %10011111
if pin0=1 then label_110
label_174: let pins = 218 ' %11011010
let pins = 37 ' %00100101
if pin0=1 then label_174
label_1D8: let pins = 218 ' %11011010
let pins = 13 ' %00001101
if pin0=1 then label_1D8
label_23C: let pins = 218 ' %11011010
let pins = 153 ' %10011001
if pin0=1 then label_23C
label_2A0: let pins = 218 ' %11011010
let pins = 73 ' %01001001
if pin0=1 then label_2A0
label_304: let pins = 218 ' %11011010
let pins = 65 ' %01000001
if pin0=1 then label_304
label_368: let pins = 218 ' %11011010
let pins = 31 ' %00011111
if pin0=1 then label_368
label_486: let pins = 218 ' %11011010
let pins = 1 ' %00000001
if pin0=1 then label_486
label_3CC: let pins = 218 ' %11011010
let pins = 25 ' %00011001
if pin0=1 then label_3CC
label_48D: let pins = 218 ' %11011010
let pins = 3 ' %00000011
if pin0=1 then label_48D
label_117: let pins = 242 ' %11110010
let pins = 159 ' %10011111
if pin0=1 then label_117
label_17B: let pins = 242 ' %11110010
let pins = 37 ' %00100101
if pin0=1 then label_17B
label_1DF: let pins = 242 ' %11110010
let pins = 13 ' %00001101
if pin0=1 then label_1DF
label_243: let pins = 242 ' %11110010
let pins = 153 ' %10011001
if pin0=1 then label_243
label_2AE: let pins = 242 ' %11110010
let pins = 73 ' %01001001
if pin0=1 then label_2AE
label_30B: let pins = 242 ' %11110010
let pins = 65 ' %01000001
if pin0=1 then label_30B
label_36F: let pins = 242 ' %11110010
let pins = 31 ' %00011111
if pin0=1 then label_36F
label_3D3: let pins = 242 ' %11110010
let pins = 1 ' %00000001
if pin0=1 then label_3D3
label_430: let pins = 242 ' %11110010
let pins = 25 ' %00011001
if pin0=1 then label_430
label_494: let pins = 242 ' %11110010
let pins = 3 ' %00000011
if pin0=1 then label_494
label_11E: let pins = 102 ' %01100110
let pins = 159 ' %10011111
if pin0=1 then label_11E
label_182: let pins = 102 ' %01100110
let pins = 37 ' %00100101
if pin0=1 then label_182
label_1E6: let pins = 102 ' %01100110
let pins = 13 ' %00001101
if pin0=1 then label_1E6
label_24A: let pins = 102 ' %01100110
let pins = 153 ' %10011001
if pin0=1 then label_24A
label_2A7: let pins = 102 ' %01100110
let pins = 73 ' %01001001
if pin0=1 then label_2A7
label_312: let pins = 102 ' %01100110
let pins = 65 ' %01000001
if pin0=1 then label_312
label_376: let pins = 102 ' %01100110
let pins = 31 ' %00011111
if pin0=1 then label_376
label_3DA: let pins = 102 ' %01100110
let pins = 1 ' %00000001
if pin0=1 then label_3DA
label_437: let pins = 102 ' %01100110
let pins = 25 ' %00011001
if pin0=1 then label_437
label_49B: let pins = 102 ' %01100110
let pins = 3 ' %00000011
if pin0=1 then label_49B
goto label_50C
Last edited: