Christmas Caroling Device with Light Display

Jessica UelmenJessica Uelmen Posts: 490
edited 2013-03-08 - 06:10:35 in Learn with BlocklyProp
Christmas Caroling Device with Light Display
·
Bring the spirit of the holidays with you anywhere using this DIY caroling device and light display! This activity demonstrates how to program four different Christmas songs to play depending on the position selected on the 5-Position Switch.· While each song is playing, red and green LEDs will blink a light pattern, unique to each song.
·
Download Source Code

Getting Started

If you are new to the BASIC Stamp microcontroller or to programming, it would be a good idea to review the following before beginning:
·
······· Complete Chapters 1-3 in What’s a Microcontroller
······· Review the Stamps in Class “Mini Project”: Playing Sheet Music with the Piezospeaker
······· Review the 5-Position Switch Documentation

Parts Required

(1) HomeWork Board with BASIC Stamp 2
The BASIC Stamp 2 Board of Education is also suitable for this activity.
(5) 470 Ω Resistors
(3) Green LEDs
(2) Red LEDs
(1) Piezospeaker
(1) 5-Position Switch

Schematics and Building the Circuits

Figure 1 is the schematic and Figure 2 is the wiring diagram for this circuit. ·Build your circuit as shown below.
·
Figure 1 – Christmas Caroler Schematic

attachment.php?attachmentid=65586
Figure 2 – Christmas Caroler Wiring Diagram
attachment.php?attachmentid=65587

Testing the Circuit

Once everything is wired, it’s good to be sure that everything is wired correctly. That way, you will always know that your circuit is functional, and won’t waste time trying to correct perfectly good code when the problem really lies in your wiring.· Run TestCarolingDevice.bs2 and make sure that:
·
······· All LEDs turn on
······· The piezospeaker plays a tone
······· All 5 positions (up, down, left, right, and pressed) display on the Debug Terminal

[color=#008000]' TestCarolingDevice.bs2[/color]
[color=#008000]' Tests that the Caroling Device is wired correctly.[/color]
 
[color=#008000]' {$STAMP BS2}[/color]
[color=#008000]' {$PBASIC 2.5}[/color]
 
[color=#020FC0]HIGH[/color][color=#000000] 15                       [/color][color=#008000]' Turn on all LEDs[/color]
[color=#020FC0]HIGH[/color][color=#000000] 14[/color]
[color=#020FC0]HIGH[/color][color=#000000] 13[/color]
[color=#020FC0]HIGH[/color][color=#000000] 12[/color]
[color=#020FC0]HIGH[/color][color=#000000] 11[/color]
 
[color=#020FC0]FREQOUT[/color][color=#000000] 8, 2000, 3000         [/color][color=#008000]' Play a tone[/color]
 
[color=#020FC0]DEBUG[/color][color=#000000] CLS,                    [/color][color=#008000]' Display directional graph[/color]
[color=#ff0000]"            "[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000],[/color]
[color=#ff0000]"     |      "[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000],[/color]
[color=#ff0000]"   -   -    "[/color][color=#000000], [/color][color=#800080]CR[/color][color=#000000],[/color]
[color=#ff0000]"     |[/color]      [color=#ff0000]"[/color][color=#000000], [/color][color=#800080]CR[/color]
 
[color=#008000]' Display which direction is pressed on the 5-Position Switch[/color]
[color=#020FC0]DO[/color]
  [color=#020FC0]IF[/color][color=#000000] ([/color][color=#800080]IN0[/color][color=#000000] = 0) [/color][color=#020FC0]THEN[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 2, 2, [/color][color=#ff0000]"<"[/color] [color=#020FC0]ELSE[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 2, 2, [/color][color=#ff0000]" "[/color]
  [color=#020FC0]IF[/color][color=#000000] ([/color][color=#800080]IN1[/color][color=#000000] = 0) [/color][color=#020FC0]THEN[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 5, 4, [/color][color=#ff0000]"v"[/color] [color=#020FC0]ELSE[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 5, 4, [/color][color=#ff0000]" "[/color]
  [color=#020FC0]IF[/color][color=#000000] ([/color][color=#800080]IN2[/color][color=#000000] = 0) [/color][color=#020FC0]THEN[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 8, 2, [/color][color=#ff0000]">"[/color] [color=#020FC0]ELSE[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 8, 2, [/color][color=#ff0000]" "[/color]
  [color=#020FC0]IF[/color][color=#000000] ([/color][color=#800080]IN3[/color][color=#000000] = 0) [/color][color=#020FC0]THEN[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 5, 2, [/color][color=#ff0000]"o"[/color] [color=#020FC0]ELSE[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 5, 2, [/color][color=#ff0000]" "[/color]
  [color=#020FC0]IF[/color][color=#000000] ([/color][color=#800080]IN4[/color][color=#000000] = 0) [/color][color=#020FC0]THEN[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 5, 0, [/color][color=#ff0000]"^"[/color] [color=#020FC0]ELSE[/color] [color=#020FC0]DEBUG[/color] [color=#800080]CRSRXY[/color][color=#000000], 5, 0, [/color][color=#ff0000]" "[/color]
  [color=#020FC0]PAUSE[/color][color=#000000] 20[/color]
[color=#020FC0]LOOP[/color]


Choosing Your Tunes
Now that we know the circuit is working, it’s time to pick the songs that we want our Caroling Device to play.· In this project, we’re going to use four of the five positions to play four different songs, and use the fifth position to stop playing a song when user desires.· For this application, four copyright-friendly songs have been chosen: We Wish You a Merry Christmas, Jingle Bells, Deck the Halls, and O Christmas Tree.
·
Once the four songs have been chosen, they should be coded in four separate programs.· This will make sure that they sound right before porting them to the main program.· For the sake of space, the code for each individual song is not listed below, but they can be downloaded from the ChristmasCarols_SourceCode.zip file attached below.
·
attachment.php?attachmentid=73742

Time to Spread Some Holiday Cheer!

At this point, we’ve got our songs fully coded, our circuit works, and we’re ready to put everything together.· By now you may have guessed that this program is going to be rather large, and is going to take up a lot of EEPROM space.· So it’s our job to make sure we make the most of what we have.
·
The first EEPROM-Eater is the space required to store the information needed to play all four songs. ·This requires four DATA directives for each song – one to store the notes, one to store the octaves, one to store the durations, and to store the dotted notes.· Is there anything we can do to eliminate some of this space?
·
Why yes, there is!· When looking at the sheet music for Jingle Bells and We Wish You a Merry Christmas, I noted that there were very few to no dotted notes.· So instead of taking up EEPROM space to save 1-2 dotted notes in a whole song, why not just increase the value in the Durations DATA directive?· It won’t be as accurate, but as long as it sounds OK, that’s what counts!
·
In order to further save memory, we’ll extensively use subroutines so we’re not repeating the same lines of code unnecessarily.· The main part of the program will branch off to four separate subroutines to play four separate songs, based on which position on the 5-Position Switch is selected:
·
DO
· IF (IN0 = 0) THEN
··· GOSUB Deck_The_Halls
· ELSEIF (IN1 = 0) THEN
··· GOSUB Jingle_Bells
· ELSEIF (IN2 = 0) THEN
··· GOSUB Merry_Christmas
· ELSEIF (IN4 = 0) THEN
··· GOSUB Christmas_Tree
· ELSE
··· PAUSE 20
· ENDIF
LOOP
·
Each song’s subroutine will then have the same basic structure: READ the note letter, octave, duration, and dot notation from its appropriate location in EEPROM and then calculate the values needed for the BASIC Stamp’s FREQOUT command.· Most of these calculations can be carried out through the use of more subroutines to keep on savin’ that memory.· For example, the LOOKUP and LOOKDOWN tables for calculating each note’s frequency will be the same for each song, and therefore can be placed in a subroutine named Get_Frequency:
·
Get_Frequency:
· LOOKDOWN noteLetter, [noparse][[/noparse]· "C",· "d",· "D",· "e",· "E",
························· "F",· "g",· "G",· "a",· "A",
························· "b",· "B",· "R",· "Q"···· ], offset
·
· LOOKUP offset,······· [noparse][[/noparse] 4186, 4435, 4699, 4978, 5274,
························· 5588, 5920, 6272, 6645, 7040,
························· 7459, 7902,··· 0,··· 0···· ], noteFreq
RETURN
·
Likewise, re-calculating a note’s frequency so that it is in the proper octave can also be placed in a subroutine named Get_Octave:
·
Get_Octave:
· noteOctave = 8 - noteOctave
· noteFreq = noteFreq / (DCD noteOctave)
RETURN
·
Next, we’ll have to determine what the light pattern will be displayed while each song is playing.· An easy way to do this is simply to assign certain LEDs to turn on when certain notes are being played.· Since the notes in each song differ from one to the other, we can ensure that the pattern of lights will be different for each song all while calling the same subroutine, Display_Color.· You may notice that the first part of this subroutine turns all of the LEDs off.· This ensures that any LED that was on for the last note will be off for current note, creating a “blinking” effect each time!
·
Display_Color:
· LOW 15: LOW 14: LOW 13: LOW 12: LOW 11
· SELECT noteLetter
··· CASE "A", "a"
····· HIGH 15
··· CASE "B", "b"
····· HIGH 14
··· CASE "C", "c"
····· HIGH 13
··· CASE "D", "d"
····· HIGH 12
··· CASE "E", "e"
····· HIGH 11
··· CASE "F", "f"
····· HIGH 15
····· HIGH 13
····· HIGH 11
··· CASE "G", "g"
····· HIGH 14
····· HIGH 12
·· ENDSELECT
RETURN
·
attachment.php?attachmentid=73743
·
Now there are two last things to consider before we can run the whole program.· First, we need to reset the index variable to 0 before playing any song.· This variable acts as a pointer to specific address locations in EEPROM, and if it wasn’t reset before each song was played, some songs might start playing from the middle, or some not at all!
·
Lastly, at the end of playing each song, we need to reset the value of noteLetter.· This is because our songs will only play if noteLetter doesn’t equal “Q” or if the center position on the 5-Position Switch is not pressed.· BUT every string of notes saved to EEPROM ends with “Q”, and if this is not reset, then the songs won’t play a second time.· In the code below, noteLetter is simply set to “R” at the end of each subroutine to prevent this from happening.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jessica Uelmen
Education Department
Parallax Inc.

Post Edited (Jessica Uelmen (Parallax)) : 8/25/2010 6:37:22 PM GMT
Allons-y!
--
@jessicauelmen
565 x 287 - 40K
554 x 443 - 676K
763 x 96 - 17K
763 x 228 - 33K

Comments

  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2009-12-04 - 18:42:32
    Now just add a battery to your board, enter and run CarolingDeviceWithLights.bs2 to start sharing holiday cheer!
    ·
    [color=#008000]' -----[noparse][[/noparse] Title ]--------------------------------------------------------------[/color]
    [color=#008000]' CarolingDeviceWithLights.bs2[/color]
    [color=#008000]' Play a variety of Christmas songs with corresponding light displays using[/color]
    [color=#008000]' the 5-Position Switch, piezospeaker, and 5 red and green LEDs.[/color]
     
    [color=#008000]' {$STAMP BS2}[/color]
    [color=#008000]' {$PBASIC 2.5}[/color]
     
    [color=#008000]' -----[noparse][[/noparse] EEPROM Data ]--------------------------------------------------------[/color]
     
    [color=#008000]' Store information needed to play "Deck the Halls"[/color]
    Notes_DTH     [color=#0000ff]DATA[/color]    [color=#ff0000]"C"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A[/color]", [color=#ff0000]"F"[/color],
                          [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"E"[/color], [color=#ff0000]"F"[/color],
                          [color=#ff0000]"C"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"F"[/color],
                          [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"E"[/color], [color=#ff0000]"F"[/color],
                          [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"G"[/color],
                          [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"E"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"E"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"C"[/color],
                          [color=#ff0000]"C"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"F"[/color],
                          [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"Q"[/color]
     
    Octaves_DTH   [color=#0000ff]DATA[/color]      7,   6,   6,   6,   6,   6,   6,   6,
                            6,   6,   6,   6,   6,   6,   6,   6,   6,
                            7,   6,   6,   6,   6,   6,   6,   6,
                            6,   6,   6,   6,   6,   6,   6,   6,   6,
                            6,   6,   6,   6,   6,   6,   7,   6,
                            6,   6,   7,   7,   7,   7,   7,   7,   7,
                            7,   6,   6,   6,   6,   6,   6,   6,
                            7,   7,   7,   7,   7,   6,   6,   6,   6
     
    Durations_DTH [color=#0000ff]DATA[/color]      4,   8,   4,   4,   4,   4,   4,   4,
                            8,   8,   8,   8,   4,   8,   4,   4,   2,
                            4,   8,   4,   4,   4,   4,   4,   4,
                            8,   8,   8,   8,   4,   8,   4,   4,   2,
                            4,   8,   4,   4,   4,   8,   4,   4,
                            8,   8,   4,   8,   8,   4,   4,   4,   2,
                            4,   8,   4,   4,   4,   4,   4,   4,
                            8,   8,   8,   8,   4,   8,   4,   4,   2
     
    Dots_DTH      [color=#0000ff]DATA[/color]      1,   0,   0,   0,   0,   0,   0,   0,
                            0,   0,   0,   0,   1,   0,   0,   0,   0,
                            1,   0,   0,   0,   0,   0,   0,   0,
                            0,   0,   0,   0,   1,   0,   0,   0,   0,
                            1,   0,   0,   0,   1,   0,   0,   0,
                            0,   0,   0,   0,   0,   0,   0,   0,   0,
                            1,   0,   0,   0,   0,   0,   0,   0,
                            0,   0,   0,   0,   1,   0,   0,   0,   0
     
    [color=#008000]' Store information needed to play "Jingle Bells"[/color]
    Notes_JB     [color=#0000ff]DATA[/color]     [color=#ff0000]"D"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"R"[/color],
                          [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"E"[/color], [color=#ff0000]"R"[/color],
                          [color=#ff0000]"E"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"g"[/color], [color=#ff0000]"R"[/color],
                          [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color],
                          [color=#ff0000]"D"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color],[color=#ff0000] "D"[/color], [color=#ff0000]"R"[/color],
                          [color=#ff0000]"D"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"E"[/color], [color=#ff0000]"R"[/color],
                          [color=#ff0000]"E"[/color], [color=#ff0000]"E"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color],
                          [color=#ff0000]"D"[/color], [color=#ff0000]"E"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"R"[/color],
                          [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color],
                          [color=#ff0000]"B"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"R"[/color],
                          [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color],
                          [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"D"[/color],
                          [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color],
                          [color=#ff0000]"B"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"R"[/color],
                          [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B[/color]",
                          [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"Q"[/color]
     
    Octaves_JB    [color=#0000ff]DATA[/color]      6,   6,   6,   6,   6,   6,
                            6,   6,   6,   6,   6,   6,   6,  6,
                            6,   7,   6,   6,   6,   6,
                            7,   7,   7,   6,   6,
                            6,   6,   6,   6,   6,   6,
                            6,   6,   6,   6,   6,   6,
                            6,   6,   7,   6,   6,   7,   7,  7,
                            7,   7,   7,   7,   6,   6,   6,
                            6,   6,   6,   6,   6,   6,
                            6,   7,   6,   6,   6,   6,
                            7,   7,   7,   7,   7,   6,   6,
                            6,   6,   6,   6,   6,   6,   6,  7,
                            6,   6,   6,   6,   6,   6,
                            6,   7,   6,   6,   6,   6,
                            7,   7,   7,   7,   7,   6,   6,
                            6,   6,   7,   7,   7,   6,   6
     
    Durations_JB  [color=#0000ff]DATA[/color]      4,   4,   4,   4,   2,   4,
                            8,   8,   4,   4,   4,   4,   2,   4,
                            4,   4,   4,   4,   2,   4,
                            2,   4,   4,   4,   2,
                            4,   4,   4,   4,   2,   4,
                            4,   4,   4,   4,   2,   4,
                            4,   4,   4,   4,   4,   4,  4,   4,
                            4,   4,   4,   4,   4,   2,  4,
                            4,   4,   2,   4,   4,   2,
                            4,   4,   4,   8,   3,   4,
                            4,   4,   4,   8,   4,   4,  4,
                            8,   8,   4,   4,   4,   4,  2,   2,
                            4,   4,   2,   4,   4,   2,
                            4,   4,   4,   8,   3,   4,
                            4,   4,   4,   8,   4,   4,  4,
                            8,   8,   4,   4,   4,   4,  1
     
    [color=#008000]' Store information needed to play "We Wish you a Merry Christmas"[/color]
    Notes_MC      [color=#0000ff]DATA[/color]    [color=#ff0000]"e"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"F"[/color],
                          [color=#ff0000]"F"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"e"[/color],
                          [color=#ff0000]"e"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"d"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"F"[/color],
                          [color=#ff0000]"e"[/color], [color=#ff0000]"e"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"a"[/color],
                          [color=#ff0000]"e"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"e"[/color],
                          [color=#ff0000]"b"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"e"[/color], [color=#ff0000]"e"[/color],
                          [color=#ff0000]"e"[/color], [color=#ff0000]"e"[/color], [color=#ff0000]"F"[/color], [color=#ff0000]"b"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"a"[/color], [color=#ff0000]"Q"[/color]
     
    Octaves_MC    [color=#0000ff]DATA[/color]      6,   6,   6,   6,   6,   6,   6,   6,
                            6,   6,   6,   7,   6,   6,   6,   6,
                            6,   7,   7,   7,   7,   6,   6,   6,
                            6,   6,   6,   6,   6,   6,
                            6,   6,   6,   6,   6,   6,   6,   6,   6,   6,
                            6,   7,   6,   6,   7,   6,
                            6,   6,   6,   6,   6,   6
     
    Durations_MC  [color=#0000ff]DATA[/color]      4,   4,   8,   8,   8,   8,   4,   4,
                            4,   4,   8,   8,   8,   8,   4,   4,
                            4,   4,   8,   8,   8,   8,   4,   4,
                            8,   8,   4,   4,   4,   2,
                            4,   4,   4,   4,   2,   4,   4,   4,   4,   2,
                            4,   4,   4,   4,   4,   4,
                            8,   8,   4,   4,   4,   2
     
    [color=#008000]' Store information needed to play "O Christmas Tree"[/color]
    Notes_CT      [color=#0000ff]DATA[/color]    [color=#ff0000]"D"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color],
                          [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"g"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color],
                          [color=#ff0000]"D"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color],
                          [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"g"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"R"[/color],
                          [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"E"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color],
                          [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"D"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color],
                          [color=#ff0000]"D"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"B"[/color],
                          [color=#ff0000]"B"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"B"[/color], [color=#ff0000]"C"[/color], [color=#ff0000]"g"[/color], [color=#ff0000]"A"[/color], [color=#ff0000]"G"[/color], [color=#ff0000]"Q"[/color]
     
    Octaves_CT    [color=#0000ff]DATA[/color]      6,   6,   6,   6,   6,   6,   6,   6,
                            6,   6,   6,   7,   6,   6,   6,
                            6,   6,   6,   6,   6,   6,   6,   6,
                            6,   6,   6,   7,   6,   6,   6,   6,
                            7,   7,   6,   7,   7,   7,   7,   7,
                            7,   7,   6,   7,   7,   7,   6,   6,
                            6,   6,   6,   6,   6,   6,   6,   6,
                            6,   6,   6,   7,   6,   6,   6
     
    Durations_CT  [color=#0000ff]DATA[/color]      4,   8,   8,   4,   4,   8,   8,   4,
                            8,   8,   8,   4,   4,   4,   4,
                            4,   8,   8,   4,   4,   8,   8,   4,
                            8,   8,   8,   4,   4,   4,   4,   8,
                            8,   8,   8,   4,   8,   8,   8,   4,
                            8,   8,   8,   4,   8,   8,   8,   4,
                            4,   8,   8,   4,   4,   8,   8,   4,
                            8,   8,   8,   4,   4,   4,   4
     
    Dots_CT       [color=#0000ff]DATA[/color]      0,   1,   0,   0,   0,   1,   0,   1,
                            0,   0,   0,   0,   0,   0,   0,
                            0,   1,   0,   0,   0,   1,   0,   1,
                            0,   0,   0,   0,   0,   0,   0,   0,
                            0,   0,   0,   1,   0,   0,   0,   1,
                            0,   0,   0,   1,   0,   0,   0,   0,
                            0,   1,   0,   0,   0,   1,   0,   1,
                            0,   0,   0,   0,   0,   0,   0
     
    [color=#008000]' -----[noparse][[/noparse] I/O Definitions ]----------------------------------------------------[/color]
    [color=#000000]speaker       PIN     8              [/color][color=#008000]' Piezospeaker connection[/color]
     
    [color=#008000]' -----[noparse][[/noparse] Variables ]----------------------------------------------------------[/color]
    [color=#000000]offset        VAR     Nib            [/color][color=#008000]' Variable space for LOOKUP table[/color]
    [color=#000000]index         VAR     Byte           [/color][color=#008000]' Index for pointing at data[/color]
     
    [color=#000000]noteDot       VAR     Bit            [/color][color=#008000]' Stores if a note is dotted or not[/color]
    [color=#000000]noteOctave    VAR     Nib            [/color][color=#008000]' Stores the octave of each note[/color]
    [color=#000000]noteLetter    VAR     Byte           [/color][color=#008000]' Stores the letter of each note[/color]
    [color=#000000]noteFreq      VAR     Word           [/color][color=#008000]' Stores the frequency of each note[/color]
    [color=#000000]noteDuration  VAR     Word           [/color][color=#008000]' Stores the duration of each note[/color]
     
    [color=#008000]' -----[noparse][[/noparse] Main Routine ]-------------------------------------------------------[/color]
    [color=#0000ff]DO[/color]
      [color=#0000ff]IF[/color][color=#000000] ([/color][color=#800080]IN0[/color][color=#000000] = 0) [/color][color=#0000ff]THEN[/color]                  [color=#008000]' If the left button pressed...[/color]
        [color=#0000ff]GOSUB[/color][color=#000000] Deck_The_Halls             [/color][color=#008000]' Play "Deck the Halls"[/color]
      [color=#0000ff]ELSEIF[/color][color=#000000] ([/color][color=#800080]IN1[/color][color=#000000] = 0) [/color][color=#0000ff]THEN[/color]              [color=#008000]'[/color] [color=#008000]If the down button is pressed...[/color]
        [color=#0000ff]GOSUB[/color][color=#000000] Jingle_Bells               [/color][color=#008000]' Play "Jingle Bells"[/color]
      [color=#0000ff]ELSEIF[/color][color=#000000] ([/color][color=#800080]IN2[/color][color=#000000] = 0) [/color][color=#0000ff]THEN[/color]              [color=#008000]' If the right button is pressed...[/color]
    [color=#000000]    GOSUB Merry_Christmas            [/color][color=#008000]'[/color] [color=#008000]Play "We Wish You a Merry Christmas"[/color]
      [color=#0000ff]ELSEIF[/color][color=#000000] ([/color][color=#800080]IN4[/color][color=#000000] = 0) [/color][color=#0000ff]THEN[/color]              [color=#008000]' If the up button is pressed...[/color]
        [color=#0000ff]GOSUB[/color][color=#000000] Christmas_Tree             [/color][color=#008000]' Play "O Christmas Tree"[/color]
      [color=#0000ff]ELSE[/color]                               [color=#008000]'[/color] [color=#008000]If anything else happens..[/color][color=#000000].[/color]
        [color=#0000ff]PAUSE[/color][color=#000000] 20                         [/color][color=#008000]' Pause for 20 ms[/color]
      [color=#0000ff]ENDIF[/color]
    [color=#0000ff]LOOP[/color]                                 [color=#008000]' Loop forever[/color]
     
    
    [color=#008000]' -----[noparse][[/noparse] Subroutine - Deck_The_Halls ]----------------------------------------[/color]
    [color=#008000]' Plays the song "Deck the Halls"[/color]
    [color=#000000]Deck_The_Halls:                      [/color][color=#008000]' Subroutine Label[/color]
    [color=#000000]  index = 0                          [/color][color=#008000]' Set index back to 0 for new songs[/color]
    [color=#008000]  ' Loop until the end of the song, or the center button is pressed[/color]
    [color=#0000ff]  DO[/color] [color=#0000ff]UNTIL[/color][color=#000000] (noteLetter = [/color][color=#ff0000]"Q"[/color][color=#000000]) OR ([/color][color=#800080]IN3[/color][color=#000000] = 0)[/color]
        [color=#0000ff]READ[/color][color=#000000] Notes_DTH + index, noteLetter: [/color][color=#0000ff]GOSUB[/color][color=#000000] Get_Frequency[/color]
        [color=#0000ff]READ[/color][color=#000000] Octaves_DTH + index, noteOctave: [/color][color=#0000ff]GOSUB[/color][color=#000000] Get_Octave[/color]
        [color=#0000ff]READ[/color][color=#000000] Durations_DTH + index, noteDuration: noteDuration = 1000 / noteDuration[/color]
        [color=#0000ff]READ[/color][color=#000000] Dots_DTH + index, noteDot[/color]
          [color=#0000ff]IF[/color][color=#000000] noteDot = 1 [/color][color=#0000ff]THEN[/color][color=#000000] noteDuration = noteDuration * 3 / 2[/color]
     
        [color=#0000ff]GOSUB[/color][color=#000000] Display_Color                           [/color][color=#008000]' Turn on LED display[/color]
        [color=#0000ff]FREQOUT[/color][color=#000000] speaker, noteDuration, noteFreq       [/color][color=#008000]' Play note[/color]
     
    [color=#000000]    index = index + 1                             [/color][color=#008000]' Increase data pointer by 1[/color]
      [color=#0000ff]LOOP[/color]
    [color=#000000]  noteLetter = [/color][color=#ff0000]"R"[/color]                                [color=#008000]' Set note letter to "R"[/color]
    [color=#0000ff]RETURN[/color]                                            [color=#008000]' Return to Main Program[/color]
     
    [color=#008000]' -----[noparse][[/noparse] Subroutine - Jingle_Bells ]------------------------------------------[/color]
    [color=#008000]' Plays the song "Jingle Bells"[/color]
    [color=#000000]Jingle_Bells:                        ' Subroutine label[/color]
    [color=#000000]  index = 0                          ' Set index back to 0 for new songs[/color]
    [color=#000000]  ' Loop until the end of the song, or the center button is pressed[/color]
      [color=#0000ff]DO[/color] [color=#0000ff]UNTIL[/color][color=#000000] (noteLetter = [/color][color=#ff0000]"Q"[/color][color=#000000]) OR ([/color][color=#800080]IN3[/color][color=#000000] = 0)[/color]
        [color=#0000ff]READ[/color][color=#000000] Notes_JB + index, noteLetter:   [/color][color=blue]GOSUB[/color][color=#000000] Get_Frequency[/color]
        [color=#0000ff]READ[/color][color=#000000] Octaves_JB + index, noteOctave: [/color][color=blue]GOSUB[/color][color=#000000] Get_Octave[/color]
        [color=#0000ff]READ[/color][color=#000000] Durations_JB + index, noteDuration: noteDuration = 900 / noteDuration[/color]
     
        [color=#0000ff]GOSUB[/color][color=#000000] Display_Color                           [/color][color=#008000]' Turn on LED display[/color]
        [color=#0000ff]FREQOUT[/color][color=#000000] speaker, noteDuration, noteFreq       [/color][color=#008000]' Play note[/color]
     
    [color=#000000]    index = index + 1                             [/color][color=#008000]' Increase data pointer by 1[/color]
      [color=#0000ff]LOOP[/color]
    [color=#000000]  noteLetter = [/color][color=#ff0000]"R"[/color]                                [color=#008000]' Set note letter to "R"[/color]
    [color=#0000ff]RETURN[/color]                                            [color=#008000]' Return to Main Program[/color]
     
    [color=#008000]' -----[noparse][[/noparse] Subroutine - Merry_Christmas ]---------------------------------------[/color]
    [color=#008000]' Plays the song "We Wish you a Merry Christmas"[/color]
    [color=#000000]Merry_Christmas:                     [/color][color=#008000]' Subroutine label[/color]
    [color=#000000]  index = 0                          [/color][color=#008000]' Set index back to 0 for new songs[/color]
    [color=#008000]  ' Loop until the end of the song, or the center button is pressed[/color]
      [color=#0000ff]DO[/color] [color=#0000ff]UNTIL[/color][color=#000000] (noteLetter = [/color][color=#ff0000]"Q"[/color][color=#000000]) OR ([/color][color=#800080]IN3[/color][color=#000000] = 0)[/color]
        [color=#0000ff]READ[/color][color=#000000] Notes_MC + index, noteLetter: [/color][color=#0000ff]GOSUB[/color][color=#000000] Get_Frequency[/color]
        [color=#0000ff]READ[/color][color=#000000] Octaves_MC + index, noteOctave: [/color][color=#0000ff]GOSUB[/color][color=#000000] Get_Octave[/color]
        [color=#0000ff]READ[/color][color=#000000] Durations_MC + index, noteDuration: noteDuration = 1000 / noteDuration[/color]
     
        [color=#0000ff]GOSUB[/color][color=#000000] Display_Color                           [/color][color=#008000]' Turn on LED display[/color]
        [color=#0000ff]FREQOUT[/color][color=#000000] speaker, noteDuration, noteFreq       [/color][color=#008000]' Play note[/color]
     
    [color=#000000]    index = index + 1                             [/color][color=#008000]' Increase data pointer by 1[/color]
      [color=#0000ff]LOOP[/color]
    [color=#000000]  noteLetter = [/color][color=#ff0000]"R"[/color]                                [color=#008000]' Set note letter to "R"[/color]
    [color=#0000ff]RETURN[/color]                                            [color=#008000]' Return to Main Program[/color]
     
    [color=#008000]' -----[noparse][[/noparse] Subroutine - Christmas_Tree ]----------------------------------------[/color]
    [color=#008000]' Plays the song "O Christmas Tree"[/color]
    [color=#000000]Christmas_Tree:                      [/color][color=#008000]' Subroutine label[/color]
    [color=#000000]  index = 0                          [/color][color=#008000]' Set index back to 0 for new songs[/color]
    [color=#008000]  ' Loop until the end of the song, or the center button is pressed[/color]
      [color=#0000ff]DO[/color] [color=#0000ff]UNTIL[/color][color=#000000] (noteLetter = [/color][color=#ff0000]"Q"[/color][color=#000000]) OR ([/color][color=#800080]IN3[/color][color=#000000] = 0)[/color]
        [color=#0000ff]READ[/color][color=#000000] Notes_CT + index, noteLetter: [/color][color=#0000ff]GOSUB[/color][color=#000000] Get_Frequency[/color]
        [color=#0000ff]READ[/color][color=#000000] Octaves_CT + index, noteOctave: [/color][color=#0000ff]GOSUB[/color][color=#000000] Get_Octave[/color]
        [color=#0000ff]READ[/color][color=#000000] Durations_CT + index, noteDuration: noteDuration = 1700 / noteDuration[/color]
        [color=#0000ff]READ[/color][color=#000000] Dots_CT + index, noteDot[/color]
          [color=#0000ff]IF[/color][color=#000000] noteDot = 1 [/color][color=#0000ff]THEN[/color][color=#000000] noteDuration = noteDuration * 3 / 2[/color]
     
        [color=#0000ff]GOSUB[/color][color=#000000] Display_Color                           [/color][color=#008000]' Turn on LED display[/color]
        [color=#0000ff]FREQOUT[/color][color=#000000] speaker, noteDuration, noteFreq       [/color][color=#008000]' Play note[/color]
     
    [color=#000000]    index = index + 1                             [/color][color=#008000]' Increase data pointer by 1[/color]
      [color=#0000ff]LOOP[/color]
    [color=#000000]  noteLetter = [/color][color=#ff0000]"R"[/color]                                [color=#008000]' Set note letter to "R" [/color]
    [color=#0000ff]RETURN[/color]                                            [color=#008000]' Return to Main Program
    
    ' -----[noparse][[/noparse] Subroutine - Get_Frequency ]-----------------------------------------
    ' Returns the frequency for each corresponding note letter in the 8th octave
    [color=#000000]Get_Frequency:                       [/color]' Subroutine label
      [color=#0000ff]LOOKDOWN[/color][color=#000000] noteLetter, [noparse][[/noparse]  [/color][color=#ff0000]"C"[/color][color=#000000],  [/color][color=#ff0000]"d"[/color][color=#000000],  [/color][color=#ff0000]"D"[/color][color=#000000],  [/color][color=#ff0000]"e"[/color][color=#000000],  [/color][color=#ff0000]"E"[/color][color=#000000],[/color]
                              [color=#ff0000]"F"[/color][color=#000000],  [/color][color=#ff0000]"g"[/color][color=#000000],  [/color][color=#ff0000]"G"[/color][color=#000000],  [/color][color=#ff0000]"a"[/color][color=#000000],  [/color][color=#ff0000]"A"[/color][color=#000000],[/color]
                              [color=#ff0000]"b"[/color][color=#000000],  [/color][color=#ff0000]"B"[/color][color=#000000],  [/color][color=#ff0000]"R"[/color][color=#000000],  [/color][color=#ff0000]"Q"[/color][color=#000000]     ], offset[/color]
      [color=#0000ff]LOOKUP[/color][color=#000000] offset,       [noparse][[/noparse] 4186, 4435, 4699, 4978, 5274,[/color]
    [color=#000000]                         5588, 5920, 6272, 6645, 7040,[/color]
    [color=#000000]                         7459, 7902,    0,    0     ], noteFreq[/color]
    [color=#0000ff]RETURN[/color]
     
    ' -----[noparse][[/noparse] Subroutine - Get_Octave ]--------------------------------------------
    ' Calculates what octave the note should be played in
    [color=#000000]Get_Octave:                          [/color]' Subroutine label
    [color=#000000]  noteOctave = 8 - noteOctave[/color]
    [color=#000000]  noteFreq = noteFreq / (DCD noteOctave)[/color]
    [color=#0000ff]RETURN
    
    [color=#008000]' -----[noparse][[/noparse] Subroutine - Display_Color ]-----------------------------------------[/color]
    [color=#008000]' Turns on LEDs based on what notes are played[/color]
    [color=#000000]Display_Color:                                   [/color][color=#008000]' Subroutine label[/color]
      LOW[color=#000000] 15: [/color]LOW[color=#000000] 14: [/color]LOW[color=#000000] 13: [/color]LOW[color=#000000] 12: [/color]LOW[color=#000000] 11         [/color][color=#008000]' Turn LEDs off[/color]
      SELECT[color=#000000] noteLetter[/color]
        CASE [color=#ff0000]"A"[/color][color=#000000], [/color][color=#ff0000]"a"[/color]
          HIGH[color=#000000] 15[/color]
        CASE [color=#ff0000]"B"[/color][color=#000000], [/color][color=#ff0000]"b"[/color]
          HIGH[color=#000000] 14[/color]
        CASE [color=#ff0000]"C"[/color][color=#000000], [/color][color=#ff0000]"c"[/color]
          HIGH[color=#000000] 13[/color]
        CASE [color=#ff0000]"D"[/color][color=#000000], [/color][color=#ff0000]"d"[/color]
          HIGH[color=#000000] 12[/color]
        CASE [color=#ff0000]"E"[/color][color=#000000], [/color][color=#ff0000]"e"[/color]
          HIGH[color=#000000] 11[/color]
        CASE [color=#ff0000]"F"[/color][color=#000000], [/color][color=#ff0000]"f"[/color]
          HIGH[color=#000000] 15[/color]
          HIGH[color=#000000] 13[/color]
          HIGH[color=#000000] 11[/color]
        CASE [color=#ff0000]"G"[/color][color=#000000], [/color][color=#ff0000]"g"[/color]
          HIGH[color=#000000] 14[/color]
          HIGH[color=#000000] 12[/color]
       ENDSELECT
    RETURN[/color][/color]
    

    _____________________________________________________________________________
    ··
    (c) 2009·by Parallax Inc - all rights reserved.··

    Post Edited (Jessica Uelmen (Parallax)) : 12/4/2009 7:03:58 PM GMT
    Allons-y!
    --
    @jessicauelmen
  • WhitWhit Posts: 4,069
    edited 2009-12-04 - 23:18:50
    Jessica! Great mini-project. It is the first time my daughter has looked interested...

    Super job.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+


    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney
    Whit+

    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney
  • WBA ConsultingWBA Consulting Posts: 2,860
    edited 2009-12-04 - 23:24:03
    Nice job Jessica!

    I'll think I will do this for my 15" tall tree that sits at my desk. Ought to go good with all the miniature Looney-toon ornaments. I'll see about adding mosfets so I can drive a handful of LEDs on each output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    WBA-TH1M Sensirion SHT11 Module
    Special Olympics Polar Bear Plunge, Mar 20, 2010
  • servelloservello Posts: 113
    edited 2009-12-05 - 05:36:39
    Thank you so very much for this timely installment. I look forward to these projects because they are in the realm of possibility for me. I have the parts, the construction is always a pleasure and is a lesson in style and of course, the code is provided. I pour over the code to see how the circuit works and I have found it very helpful.

    Please try to keep these going and keep it in the BS2 family. I say that not only because that is the stamp that I use, but also for the reason that if someone has the ability, intelligence and experience in using your Prop or SX chips they are probably not in need of this type of instruction.

    Thanks again,
    Dominic

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Deus tantum me iudicabit
  • MichelBMichelB Posts: 154
    edited 2009-12-05 - 09:19:49
    Hi Dear Jessica, I don't have a 5-Position Switch and at this date it's to late to order it. Is this program may run on a PDB (8 active-low pushbuttons) without any modification?

    Thank you in advance.
  • PrettybirdPrettybird Posts: 269
    edited 2009-12-05 - 10:15:15
    · Very nice. Just in time for the holidays.· yeah.gif
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-12-05 - 14:23:28
    MichelB said...
    I don't have a 5-Position Switch and at this date it's too late to order it. Is this program may run on a PDB (8 active-low pushbuttons) without any modification?
    The answer is in the program.·

    Given:

    DO
    · IF (IN0 = 0) THEN
    ··· GOSUB Deck_The_Halls
    · ELSEIF (IN1 = 0) THEN
    ··· GOSUB Jingle_Bells
    · ELSEIF (IN2 = 0) THEN
    ··· GOSUB Merry_Christmas
    · ELSEIF (IN4 = 0) THEN
    ··· GOSUB Christmas_Tree
    · ELSE
    ··· PAUSE 20
    · ENDIF
    LOOP

    a DIP switch assembly could be used, the 5-position switch allows only one contact at a time.
  • MichelBMichelB Posts: 154
    edited 2009-12-05 - 14:39:08
    PJ Allen, thank you for your reply. If I understand, when a button (active-low) is pressed the related IN = 0, is it true?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2009-12-05 - 15:51:50
    You're using a PDB and its push-buttons and DIP switches are pulled high (V_cc).· So, when the button or switch is closed then the INPUT = "0" (V_ss.)· The push-buttons are the better option.

    See 'Page 4 of 9' --

    http://www.parallax.com/Portals/0/Downloads/docs/prod/schem/PDB-RevD-Schematic.pdf
  • MichelBMichelB Posts: 154
    edited 2009-12-05 - 16:05:05
    It runs very well with pushbuttons and the sound is better than with the small piezo speaker.

    Thank you again.
  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2009-12-08 - 17:33:41
    Wow! Thanks everyone for the positive feedback - what a great way to start the week. [noparse]:)[/noparse]

    I'm so glad that everyone is enjoying this little project - it was a lot of fun to put together, and I'm glad it's doing its job and spreading some holiday cheer. This is my absolute most favorite time of year, and I'm happy to share it with you all.

    @servello - As long as there are people who enjoy these Mini Projects, we will continue making them. Of course kind words from customers always help to keep them going - thanks! [noparse];)[/noparse]

    Happy Chrismachanukwanzika everyone!

    -- Jessica

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jessica Uelmen
    Education Department
    Parallax Inc.
    Allons-y!
    --
    @jessicauelmen
  • AlexCantuAlexCantu Posts: 2
    edited 2009-12-13 - 21:29:43
    Great work! joust in time for my christmas tree, thank you very much, keep the beautiful ideas flowing.
    Alex.turn.gif
  • JohnVolzJohnVolz Posts: 1
    edited 2010-02-18 - 14:11:43
    Jessica this is great. I take it you could use this not only for Christmas but program it for all sorts of events such as halloween, valentines day etc. Thanks for the cool guide.
    Lipo 6 | Xenadrine

    Post Edited (JohnVolz) : 7/28/2010 4:43:35 PM GMT
  • SandhuamarinderSandhuamarinder Posts: 85
    edited 2010-02-21 - 10:32:23
    As you work for Parallax or what ever I had a question for u Sir
    Sir i wants to read my text on Speaker man piezoelectric speaker kind of suks yeah.gif man and it only freqout music that what·i know wink.gif till now can we throw text or voice kind of stuff on speaker smurf.gif that would be really cool i want Answer on Student Level. I am student·idea.gif . Like Welcome to this and that.

    Thanks for the Codes man for the Christmas. Man why u need to use that direction joystick. Or maybe ur breadboard is small lol thats why
    When u can do that with 4 push buttons when button 1 = 1 then freqout this when button2= 1 then freqout this and when button3= 1 then freqout this and when button4= 1 then freqout this. Man your joystick is of no use but man it would be more use full for controlling robot Arm but not that one bigger and nice one man kids use to play games with that kind. And need to 2 joystick for that. Or lol advertisement for the new item.

    ·
  • AttorneyJonAttorneyJon Posts: 10
    edited 2010-12-07 - 16:30:10
    Nice project, Jessica. I've convinced everyone that I'm a genuis -- well, they already knew that, but....

    Anyway, just a comment: I did have some trouble with this project. I spent the better part of an hour comparing the schematic with the wiring diagram, supra, trying to figure out how you connected VCC on the switch to +5 volts. So, I watched your youtube clip, hit pause at the right time, and whamoo, figured it out! The wire is "hidden" underneath the Switch.

    So, perhaps I haven't convinced anyone that I'm a genuis, but just that I'm completely new to electronics. I thought, though, that I'd comment in case anyone was also "new" and couldn't figure it out either.

    Awesome job!
  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2010-12-08 - 12:01:37
    @AttorneyJon: Thanks so much for your kind words! And yes, the wiring was rather sneaky of me, I've just got to make sure you're on your toes! Plus, I'm a little OCD, so the fewer amount of wires hanging off the board, the better. :]

    And welcome to this "Wonderful World of Electronics", we're happy to have you here!

    Cheers,
    Jessica
    Allons-y!
    --
    @jessicauelmen
  • turbosupraturbosupra Posts: 1,088
    edited 2010-12-22 - 19:54:01
    Very cool project

    @AttorneyJon ... if you have a Supra, you should join the automotive group, let me know if you are interested
  • AttorneyJonAttorneyJon Posts: 10
    edited 2011-01-05 - 17:35:31
    @turbosupra:

    Sorry no Supra here, just a gas guzzling jeep. However, I appreciate the invite.

    Over the holidays I managed -- somehow -- to build a great amplifier for this project. I used two integrated circuits: The 272 and the 386. The 272 acts as a preamplifier and the 386 as a power amplifier. The neighbors were singing along to my (our) Christmas Caroling Device. If I can figure out a way to do it, I'll try and post the schematic or a picture of the amplifier.

    Anyways, VAS-Y!
  • Carol HazlettCarol Hazlett Posts: 300
    edited 2012-11-21 - 20:16:48
    Wonderful project Jessica! I liked so much I made it on my PDB and used it as my Holiday greeting this year. See it on the Facebook page for Robothon. facebook.com/Robothon
    Carol Lynn Hazlett
    carolhaz391@gmail.com

    In the birthing of any machine there is that moment when it actually works. It is always fresh and astounding for me...............Red Whittaker

  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2012-11-26 - 10:37:09
    Very cool, Carol! I love the additional LEDs, more blinky is always better. :thumb:

    Thanks for sharing!
    Allons-y!
    --
    @jessicauelmen
  • AttorneyJonAttorneyJon Posts: 10
    edited 2012-12-10 - 17:27:07
    Ah...the Christmas Caroling Device is back for another year of Happy Caroling! So, Jessica, could you review with us "non-pros" out there how to amplify this bad boy? Please?

    Thank you and Happy Holidays!
  • Jessica UelmenJessica Uelmen Posts: 490
    edited 2012-12-11 - 08:30:34
    Ah, that would be an excellent version 2.0. Though I'm afraid I spend my time this year on a different project, which should be released soon. :innocent:

    However, Andy Lindsay actually wrote a great tutorial on how to amplify a piezospeaker. You can find it here.

    Happy holidays!
    Allons-y!
    --
    @jessicauelmen
  • AdyenAdyen Posts: 7
    edited 2015-10-15 - 13:38:48
    That amazing work. Really apriciatable task you have done. cellphone repair in regina I am also doing work on my project and after saw this i have got many answers of my questions about the LED. Thanks for sharing such a informative work.
Sign In or Register to comment.