I know this is probably way below the programming level of most of you but i am totally stuck! I am try to write a program that will display the ABC's on a 7 segment display(not all letters will work i know) and play the ABC song simultaneously.The problem is i dont know anything about music and my programming knowledge is basic at best. I have the 7 segment display part down. The music i am having a hard time with and getting both portions to work together. I am using:
1 Basic Stamp kit from paralax
stamp board
7 segment display
a push button
pzieoelectric speaker
associated wire/ resistors
here is the program i have so far....
'{$STAMP BS2}
'{$PBASIC 2.5}
DEBUG "Program Running!"
IF IN3 = 3 THEN
Notes DATA "C","C","G","G","A","A","G","F","F","E","E",
"D","D","D","C","G","G","F","F","F","E","E","A","G","G","G","F",
"E","E","A","Q"
Octaves DATA 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,7, 7, 7, 7, 7, 7
Durations DATA 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4,
8, 8, 8, 8, 2, 4, 4, 2, 2, 2, 4, 4, 2, 4, 4, 4, 2, 4, 4, 2
Dots DATA 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0
BeatsPerMin CON 200
index VAR Byte
offset VAR Nib
noteLetter VAR Byte
noteFreq VAR Word
noteDuration VAR Word
noteOctave VAR Nib
noteDot VAR Bit
wholeNote VAR Word
wholeNote = 60000 / BeatsPerMin * 4
DO UNTIL noteLetter = "Q"
READ Notes + index, noteLetter
LOOKDOWN noteLetter, [ "C", "d", "D", "e", "E",
"F", "g", "G", "a", "A",
"b", "B", "P", "Q" ], offset
LOOKUP offset, [ 2093, 4435, 4699, 4978, 5274,
5588, 3136, 6272, 6645, 7040,
7459, 7902, 0, 0 ], noteFreq
READ Octaves + index, noteOctave
noteOctave = 8 - noteOctave
noteFreq = noteFreq / (DCD noteOctave)
READ Durations + index, noteDuration
noteDuration = WholeNote / noteDuration
READ Dots + index, noteDot
IF noteDot = 1 THEN noteDuration = noteDuration * 3 / 2
FREQOUT 5, noteDuration, noteFreq
index = index + 1
LOOP
OUTH = %00000000 ' OUTH initialized to low.
DIRH = %11111111 ' Set P8-P15 to all output-low.
' Digit:
' BAFG.CDE
DO
IF IN3 = 1 THEN
OUTH = %11110101 ' A
PAUSE 1000
OUTH = %00110111 ' b
PAUSE 1000
OUTH = %01100011 ' C
PAUSE 1000
OUTH = %10010111 ' d
PAUSE 1000
OUTH = %01110011 ' E
PAUSE 1000
OUTH = %01110001 ' F
PAUSE 1000
OUTH = %11110110 ' g
PAUSE 1000
OUTH = %10010101 ' h
PAUSE 1000
OUTH = %10000100 ' I
PAUSE 1000
OUTH = %10000111 ' j
PAUSE 1000
OUTH = %00100011 ' L
PAUSE 1000
OUTH = %11010110 ' m
PAUSE 1000
OUTH = %00010101 ' n
PAUSE 1000
OUTH = %11100111 ' O
PAUSE 1000
OUTH = %11110001 ' P
PAUSE 1000
OUTH = %11111100 ' q
PAUSE 1000
OUTH = %00010001 ' r
PAUSE 1000
OUTH = %01110110 ' s
PAUSE 1000
OUTH = %00000111 ' u
PAUSE 1000
OUTH = %01110011 ' w
PAUSE 1000
OUTH = %10110101 ' x
PAUSE 1000
OUTH = %10110110 ' y
PAUSE 1000
OUTH = %11010011 ' z
PAUSE 1000
DIRH = %00000000 ' I/O pins to input,
' segments off.
ENDIF
LOOP
ENDIF
ANY help would be GREATLY appreciated! Thank you!
1 Basic Stamp kit from paralax
stamp board
7 segment display
a push button
pzieoelectric speaker
associated wire/ resistors
here is the program i have so far....
'{$STAMP BS2}
'{$PBASIC 2.5}
DEBUG "Program Running!"
IF IN3 = 3 THEN
Notes DATA "C","C","G","G","A","A","G","F","F","E","E",
"D","D","D","C","G","G","F","F","F","E","E","A","G","G","G","F",
"E","E","A","Q"
Octaves DATA 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,7, 7, 7, 7, 7, 7
Durations DATA 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4,
8, 8, 8, 8, 2, 4, 4, 2, 2, 2, 4, 4, 2, 4, 4, 4, 2, 4, 4, 2
Dots DATA 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0
BeatsPerMin CON 200
index VAR Byte
offset VAR Nib
noteLetter VAR Byte
noteFreq VAR Word
noteDuration VAR Word
noteOctave VAR Nib
noteDot VAR Bit
wholeNote VAR Word
wholeNote = 60000 / BeatsPerMin * 4
DO UNTIL noteLetter = "Q"
READ Notes + index, noteLetter
LOOKDOWN noteLetter, [ "C", "d", "D", "e", "E",
"F", "g", "G", "a", "A",
"b", "B", "P", "Q" ], offset
LOOKUP offset, [ 2093, 4435, 4699, 4978, 5274,
5588, 3136, 6272, 6645, 7040,
7459, 7902, 0, 0 ], noteFreq
READ Octaves + index, noteOctave
noteOctave = 8 - noteOctave
noteFreq = noteFreq / (DCD noteOctave)
READ Durations + index, noteDuration
noteDuration = WholeNote / noteDuration
READ Dots + index, noteDot
IF noteDot = 1 THEN noteDuration = noteDuration * 3 / 2
FREQOUT 5, noteDuration, noteFreq
index = index + 1
LOOP
OUTH = %00000000 ' OUTH initialized to low.
DIRH = %11111111 ' Set P8-P15 to all output-low.
' Digit:
' BAFG.CDE
DO
IF IN3 = 1 THEN
OUTH = %11110101 ' A
PAUSE 1000
OUTH = %00110111 ' b
PAUSE 1000
OUTH = %01100011 ' C
PAUSE 1000
OUTH = %10010111 ' d
PAUSE 1000
OUTH = %01110011 ' E
PAUSE 1000
OUTH = %01110001 ' F
PAUSE 1000
OUTH = %11110110 ' g
PAUSE 1000
OUTH = %10010101 ' h
PAUSE 1000
OUTH = %10000100 ' I
PAUSE 1000
OUTH = %10000111 ' j
PAUSE 1000
OUTH = %00100011 ' L
PAUSE 1000
OUTH = %11010110 ' m
PAUSE 1000
OUTH = %00010101 ' n
PAUSE 1000
OUTH = %11100111 ' O
PAUSE 1000
OUTH = %11110001 ' P
PAUSE 1000
OUTH = %11111100 ' q
PAUSE 1000
OUTH = %00010001 ' r
PAUSE 1000
OUTH = %01110110 ' s
PAUSE 1000
OUTH = %00000111 ' u
PAUSE 1000
OUTH = %01110011 ' w
PAUSE 1000
OUTH = %10110101 ' x
PAUSE 1000
OUTH = %10110110 ' y
PAUSE 1000
OUTH = %11010011 ' z
PAUSE 1000
DIRH = %00000000 ' I/O pins to input,
' segments off.
ENDIF
LOOP
ENDIF
ANY help would be GREATLY appreciated! Thank you!