Welcome to the Liberty Basic Science Programming Page. I hope this page will offer interested parties many ideas, solutions, and interesting LB programming code that will enrich your teaching/learning experience in the field of science. I have been a science teacher for longer than I wish to admit. I still enjoy the learning, however, and especially love writing programs in Liberty Basic that help me to get the point across, or sometimes, help me manage my classroom.
I would like to get things off to a good start by posting some code to a program I just finished today involving the spectral lines produced by quantum electron transitions. The program calculates wavelengths of the Balmer lines of the hydrogen spectrum and shows the lines as they would appear in a spectroscope. Please feel free to use this and any other programs you find here.
Also- don't be shy about posting you own code or maybe a program you have been thinking about writing. This is a place for sharing information and ideas.--Scott
'**********************************************************
'This program uses the Rydberg modification of the Balmer
'formula to calculate the wavelength of light produced when
'an electron returns to energy level 2 from one of 5 higher
'energy levels. It also simulates the color of the light in the
'hydrogen spectrum produced when this transition occurs.
'***********************************************************
'Window set ups
''***********************************************************
nomainwin
WindowWidth = 640
WindowHeight = 660
UpperLeftX = int((DisplayWidth-WindowWidth)/2)
UpperLeftY = int((DisplayHeight-WindowHeight)/2)
graphicbox #w.g, 10, 10, 600, 500
statictext #w.s, "Enter principle quantum # 3-7 in the box then click 'Save' ", 10, 600, 550, 30
textbox #w.tb1, 10, 520, 200, 32
textbox #w.tb2, 20,100,300,32
textbox #w.tb3, 20,150,300,32
textbox #w.tb4, 20,200,300,32
button #w.b1, "Save", [entered], LR, 300, 40, 60, 30
open "Hydrogen Emission Spectra" for window as #w
#w, "trapclose [quit]"
#w.tb1 "!font arial 16 bold"
#w.s "!font arial 12"
#w.tb1 "!setfocus"
'*****************************************************
'Draw wavelength ruler and make marks
'*****************************************************
#w.g, "goto 50 400"
#w.g, "down"
#w.g, "goto 50 450"
#w.g, "goto 550 450"
#w.g, "goto 550 400"
#w.g, "flush"
#w.g, "goto 50 400"
x = 50
y = 400
z = 425
#w.g, "up"
#w.g, "goto ";x;" ";z
for i = 1 to 9
x = x + 50
#w.g, "goto ";x;" ";y
#w.g, "down"
#w.g, "goto ";x;" ";z
#w.g, "up"
next i
x = 50
y = 400
z = 410
#w.g, "up"
#w.g, "goto ";x;" ";z
for i = 1 to 100
x = x + 5
#w.g, "goto ";x;" ";y
#w.g, "down"
#w.g, "goto ";x;" ";z
#w.g, "up"
next i
x = 50
y = 400
z = 425
for j = 1 to 19
x = x + 25
#w.g, "goto ";x;" ";y
#w.g, "down"
#w.g, "goto ";x;" ";z
#w.g, "up"
next j
'**************************************************
'print the wavelengths in nm
'**************************************************
x = 95
y = 430
d = 300
#w.g,"down"
#w.g, "place ";x;" ";y
print #w.g, "\";d
for j = 1 to 8
d = d+50
x = x + 50
#w.g, "place ";x;" ";y
print #w.g, "\";d
next j
#w.g, "flush"
#w.g, "up"
#w.g, "goto 50 400"
#w.g, "down"
x = 550:y = 350
print #w.g, "backcolor white"
print #w.g, "color white"
print #w.g, "boxfilled ";x;" ";y
#w.g, "goto 50 400"
#w.g, "down"
x = 550
print #w.g, "backcolor black"
print #w.g, "box ";x;" ";y
print #w.g, "boxfilled ";x;" ";y
print #w.g,"flush"
wait
'**************************************************
'Show emission line in response to wavelength entry
'**************************************************
[entered]
#w.tb1 "!contents? reply$"
n =val( reply$)
'****************************************************
'calculation
'****************************************************
c = (1/4)-(1/n^2)
L = 1/(1.097e7 *c)
i = 9
rounded = int(L*10^i +0.5) / 10^i
wavelength = rounded * 1e9
print #w.tb2, "1.097e7 * [1/2^2 - 1/";n^2;"] = 1/lambda"
print #w.tb3, "lambda = 1/(1.907e7 * ";c;")"
print #w.tb4, "wavelength = ";wavelength;" nm"
select case wavelength
case 656
#w.g,"up"
#w.g,"color red"
#w.g,"backcolor red"
#w.g, "size 5"
#w.g,"goto 457 355"'355 use for all
#w.g,"down"
#w.g,"goto 457 394"'394 use for all
#w.g,"flush"
wait
case 486
#w.g,"up"
#w.g,"color cyan"
#w.g,"backcolor cyan"
#w.g, "size 5"
#w.g,"goto 286 355"'355 use for all
#w.g,"down"
#w.g,"goto 286 394"'394 use for all
#w.g,"flush"
wait
case 434
#w.g,"up"
#w.g,"color 130 100 215"
#w.g,"backcolor 130 100 215"
#w.g, "size 5"
#w.g,"goto 235 355"'355 use for all
#w.g,"down"
#w.g,"goto 235 394"'394 use for all
#w.g,"flush"
wait
case 410
#w.g,"up"
#w.g,"color 110 10 180"
#w.g,"backcolor 110 10 180"
#w.g, "size 5"
#w.g,"goto 210 355"'355 use for all
#w.g,"down"
#w.g,"goto 210 394"'394 use for all
#w.g,"flush"
wait
case 397
#w.g,"up"
#w.g,"color 70 0 120"
#w.g,"backcolor 70 0 120"
#w.g, "size 5"
#w.g,"goto 200 355"'355 use for all
#w.g,"down"
#w.g,"goto 200 394"'394 use for all
#w.g,"flush"
wait
case else
wait
end select
wait
[quit]
close #w
end
Welcome to the Liberty Basic Science Programming Page. I hope this page will offer interested parties many ideas, solutions, and interesting LB programming code that will enrich your teaching/learning experience in the field of science. I have been a science teacher for longer than I wish to admit. I still enjoy the learning, however, and especially love writing programs in Liberty Basic that help me to get the point across, or sometimes, help me manage my classroom.
I would like to get things off to a good start by posting some code to a program I just finished today involving the spectral lines produced by quantum electron transitions. The program calculates wavelengths of the Balmer lines of the hydrogen spectrum and shows the lines as they would appear in a spectroscope. Please feel free to use this and any other programs you find here.
Also- don't be shy about posting you own code or maybe a program you have been thinking about writing. This is a place for sharing information and ideas.--Scott