Shop OBEX P1 Docs P2 Docs Learn Events
Parallax 2x16 Serial LCD (27977) Backlit, w/ Spkr - Example Prop snd SPIN code?? — Parallax Forums

Parallax 2x16 Serial LCD (27977) Backlit, w/ Spkr - Example Prop snd SPIN code??

tdg8934tdg8934 Posts: 126
edited 2012-04-12 23:21 in Propeller 1
I bought one of these from Radio Shack a week or so back and it says that version F has a speaker for music but there is no example code for the Propeller (nor BS2).

I had a few of these in an earlier version when I programmed the SX chip sometime back but wanted to hear the sound capability in this new one for the Propeller.

Why is the released datasheet incomplete?

Has anyone written any example code for the music tones? I'm a bit surprised no one has brought this up yet - from what I searched on in the forum posts.

I'm just learning the Propeller and would like somewhere's to start as I know nothing about music either.

Thanks!

Comments

  • RDL2004RDL2004 Posts: 2,554
    edited 2012-04-11 17:46
    Version 3.0 of the documentation includes the commands for playing musical notes.

    http://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/27976-7-9-ParallaxSerialLCD-v3.0.pdf

    and the old kickstarts page has some basic code examples.


    http://sites.google.com/site/parallaxinretailstores/home/2x16-serial-lcd-backlit
  • tdg8934tdg8934 Posts: 126
    edited 2012-04-12 01:58
    RDL2004,

    I didn't know about the Kickstart site. Thanks. However, version 3 nor the Kickstart site has example code on how it is implemented to let's say play a tune in either the BS2 or Propeller. Commands and documentation are nice about the notes but not complete if the user isn't shown HOW they are supposed to be implemented like they barely do for the basic LCD commands for text.

    I'm not trying to be negative but just pointing out that version 3 of the document needs to be updated for music/notes implementation for the Propeller/BS2 (especially if they are being sold in the off the Parallax website for new users not knowing what to do).

    I can figure this out as I have written many SX/B programs for the LCD before, but it would have been nice to have had example code possibly showing tricks/tips or a good way to do this for Music on the Propeller and BS2.

    Thanks again.
  • WBA ConsultingWBA Consulting Posts: 2,933
    edited 2012-04-12 23:21
    tg8934, I can somewhat agree because I had the same trouble trying to figure out how to handle music with the new LCD. However, after digging deeper and talking with a few people with more knowledge than my own, it was brought to my attention that although the datasheet lacks demo code, it does contain all of the necessary information to do nearly anything with music notes. If you have working knowledge of using the propeller and some basic objects like Full Duplex Serial or Simple Serial, you would also have the required knowledge to make the LCD tend to your musical needs. Of course, for us newbies, we don't already have that fully working knowlede. Here is a breakdown of how I figured things out:

    To send commands from the command set, the datasheet has you covered by explaining that the appropriate bytes need to be sent. For example, to clear the screen and turn on the backlight:
    ' for the propeller
    lcd.tx(12)
    lcd.tx(17)
    
    'for a stamp
    SEROUT TxPin, Baud19200, [12]
    SEROUT TxPin, Baud19200, [17]
    

    So, using the same methods, we can send commands from the command set table to play an 'A' quarter note. Decimal 210 sets the note length to a quarter and decimal 220 plays an A note at whatever length and scale is currently active.
    ' for the propeller
    lcd.tx(210)
    lcd.tx(220)
    
    'for a stamp
    SEROUT TxPin, Baud19200, [210]
    SEROUT TxPin, Baud19200, [220]
    

    So, here is a short little bit of SPIN code where I laid out the music data in a DAT table
    ' messing with music 
      repeat idx from 0 to 8    ' send the first 8 "byte sets" to the LCD
        lcd.tx(muzak[idx])
    
      repeat idx from 0 to 8    ' send the 2nd 8 "bytes sets" to the LCD
        lcd.tx(muzak2[idx])
        
    
    DAT
    
      Muzak       byte      210, 216, 220, 226, 230, 217, 226, 230, 220
      '                    1/16, 4th, A   , D#,  G,  5th, D# , G ,  A 
      Muzak2      byte      210, 216, 220, 220, 220, 211, 220, 220, 220
      '                    1/16, 4th, A  , A  , A  , 1/8, A  , A  , A
    

    Once a length or scale has been setThe entire code and more explanations for it is on this thread here, where someone had the same question as you.

    As for reading music, here are a couple simple pictures that help me.

    Lettered music scale:
    piano-notes-chart.gif


    Note length explanation:
    Wpid-learn-to-read-music-noteslearning-how-to-play-pianhghgmhhmgo-at-homeonline-4c5609a1a0d4b.gif
Sign In or Register to comment.