Candy Candy (Old Japanese cartoon) Melody with PIC12F675


+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Aug 2011
    Location
    Guadalajara, México
    Posts
    28

    Default Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Hi, this is my implementation of the ending song of an anime serie of my childhood, please give a try...

    Code:
    '****************************************************************
    '*  Name    : Candy12F675                                       *
    '*  Author  : Ivan Rosales - Guadalajara, Jalisco, México       *
    '*  Notice  : Copyright (c) 2011 Ivan Rosales                   *
    '*          : All Rights Reserved                               *
    '*  Date    : 31/07/2011                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : Reproduce la melodía "Ashita ga Suki",            *
    '*          : de la serie infantil japonesa "Candy Candy"       *
    '****************************************************************
    'Si se usa una pequeña bocina, poner un capacitor de 
    '10uF ó 22uF en serie con ésta.
    '[Pin 2]___[+Cap 10uF-]___[+Bocina-]___Tierra
    'Si se usa piezo-eléctrico, poner directo del pin 2 a tierra.
    'Conectar un LED del Pin 5 a tierra.
    
    '________________________________________________________________
    'Letra:
    'En mi ventana veo brillar,
    'las estrellas muy cerca de mí,
    'cierro los ojos, quiero soñar,
    'con un dulce porvenir...
    
    'Quiero vivir y disfrutar,
    'la alegría de la juventud,
    'no habrá noche para mí,
    'sin estrellas que den luz...
    
    'Gira, gira, carrusel,
    'tus ruedas de cristal
    'recorriendo mil caminos
    'tu destino encontrarás...
    
    'Candy, Candy, Candy, Candy.
    '________________________________________________________________
    
     
    'Configuración del PIC:
    @ Device PIC12F675,WDT_ON,PWRT_ON,PROTECT_OFF,MCLR_OFF,BOD_OFF
    ansel=0             'No usar ADC's las entradas serán digitales
    cmcon=7             'No usar comparadores analógicos
    trisio=%011011      'GP2 y GP5 Serán salidas 
    DEFINE OSCCAL_1K 1  'Auto-Calibración del reloj interno 
    
    'Declaración de Variables:
    LED var gpio.2
    Piezo var gpio.5
    Cont var byte      
    Nota var byte   
    Dur var byte  
    Largo var byte  
    
    
    'Programa Principal:    
    Pause 500              'Pausa de .5 Seg para inicializar bien el PIC 
    largo=149              
    Bucle:
    if largo=149 then      'Arreglo para que repita el estribillo
    largo=65               'Reproduce las primeras 65 notas
    else
    largo=149              'Reproduce todas las 149 notas 
    endif
    for cont = 0 to largo 
    'Lista de las notas musicales, el 0 es silencio:
    lookup cont,[98,0,98,0,98,0,98,0,98,0,94,0,90,0,98,0,_ 
    98,0,98,0,98,0,102,0,99,0,98,0,98,0,99,0,94,0,_ 
    94,0,94,0,98,0,99,0,99,0,99,0,98,0,94,0,90,0,_ 
    90,0,98,0,94,0,90,0,88,0,94,0,90,0,_ 
    105,0,105,0,105,0,105,0,108,0,109,0,108,0,_ 
    105,0,102,0,102,0,102,0,108,0,105,0,_ 
    98,0,102,0,99,0,98,0,94,0,_ 
    105,0,108,0,109,0,105,0,_ 
    105,0,108,0,109,0,105,0,_ 
    105,0,108,0,109,0,111,0,_ 
    109,0,108,0,109,0,109,0,108,0,109,0,109,0,108,0,109,0,111,0,108,0,109,0],nota 
    'Lista de las duraciones de cada nota y silencio:
    lookup cont,[20,4,20,4,20,4,40,4,20,4,20,4,20,4,60,22,_ 
    20,4,20,4,40,4,40,2,20,4,20,4,20,4,20,4,60,22,_ 
    20,4,20,4,20,4,20,4,60,16,20,4,20,4,20,4,60,22,_ 
    20,4,20,4,40,4,40,4,20,4,40,4,80,44,_ 
    20,4,20,4,20,4,60,4,20,4,20,4,60,44,_ 
    20,4,40,4,60,4,20,4,40,4,60,44,_ 
    20,4,40,4,20,4,40,4,60,44,_ 
    20,4,20,4,20,4,40,44,_ 
    20,4,20,4,20,4,40,44,_ 
    20,4,20,4,40,4,100,44,_ 
    20,4,20,4,60,40,20,4,20,4,60,50,20,4,20,4,80,50,20,4,40,4,100,4],dur 
    
    if nota=0 then      'Arreglo para que encienda el LED al ritmo de la melodía 
    led=0 
    else 
    led=1 
    endif
    
    Sound piezo,[nota,dur]  'Reproduce una nota (o silencio)
    next                
    if largo=149 then pause 3000 'Si es el final de la melodía hace una pausa
    Goto bucle  'Repite indefinidamente la melodía
    end

  2. #2
    Join Date
    Apr 2003
    Location
    Cambridge - UK
    Posts
    903


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Re posted to Projects - 'Music' area

    A schematic would be a great addition to the code example

    thanks for your contribution

  3. #3
    Join Date
    Aug 2011
    Location
    Guadalajara, México
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Sorry, the schematic is very simple, you can use a small speaker with a 10uF - 22uF electrolitic capacitor in series or you can use a piezoelectric directly connected between pin 2 and ground:

    Code:
                 PIC12F675
        10uF        ___
         \]      -o|°  |o-
     .---|]-------o|   |o-
     |   /]+     -o|   |o-    LED
     |           -o|___|o----->|--.
     |                            |
     |                            |
     |                            |
     | +  __ /|                   |
     '---|  | | Small Speaker     |
     .---|__| |                   |
     |       \|                   |
     |                            |
     '----------------------------'
                    |
                   ===
                   GND

  4. #4
    Join Date
    Apr 2003
    Location
    Cambridge - UK
    Posts
    903


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Thanks, your project has been updated. its here Really appreciate your taking time to add the scematic. It maybe simple, but many beginners really need that little bit of extra info.

  5. #5
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    ivanrosales,

    Your project is too cool , so I had to give it a try. I made some changes to make it work with a PIC18F4550. Thank you.

    Robert

    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  6. #6
    Join Date
    Aug 2011
    Location
    Guadalajara, México
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Nice implementation Robert!, the original melody's name is Ashita Ga Suki:



    The PBP's Sound statement do all the trick, I just feed it with the result of the two lookup lists, one is for the PBP's Notes values an the other is for the duration (notes and silences).
    In the "first pass" only the first 65 notes are played and then the whole 149.

  7. #7
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Quote Originally Posted by ivanrosales View Post
    The PBP's Sound statement do all the trick, I just feed it with the result of the two lookup lists, one is for the PBP's Notes values an the other is for the duration (notes and silences).
    In the "first pass" only the first 65 notes are played and then the whole 149.
    Yes, the code is pretty simple. The hard part, at least for me, is feeding the right note values and durations to the code. I guess that you have some knowledge in music theory.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  8. #8
    Join Date
    Aug 2011
    Location
    Guadalajara, México
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Robert, in fact I don't have music knowledge, what I did was somewhat cheating.
    There is a nice Android app called xPiano, this app saves what you play in it as a txt file, then I made a "keyword" spreadsheet in excel to convert the xPiano notes to PBP's SOUND values this way I only have to figure out the durations...

    Your mission Robert, should you decide to accept it is...
    Figure out the note durations for the Super Mario Bros. melody, you can find my spreadsheet with the notes and the "keyword" list for xPiano in this link: http://dl.dropbox.com/u/29237304/xPiano-PIC.xls

    Kind regards.

    Ivan.

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,587


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Hi, Ivan

    Your mission is to make a search on this Forum with the "BeepMaster" Keyword ...

    And Robert will be rid of that terrible curse ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  10. #10
    Join Date
    Aug 2011
    Location
    Guadalajara, México
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Wow!
    Alain, the BeepMaster project from flipper_md is very clever indeed, but with it you will kill the "Hand Made" fun for Robert

    Thanks for point us towards the right direction!

    When the "light" slaps my face this way, I feel pretty the same than when my big brother told me that "Santa" doesn't exists...

    Regards.

    Ivan.

  11. #11
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,587


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Quote Originally Posted by ivanrosales View Post
    Wow!


    When the "light" slaps my face this way, I feel pretty the same than when my big brother told me that "Santa" doesn't exists...

    Regards.

    Ivan.
    Hi, Ivan ...

    Santa exists ... I did meet him here : http://www.santaclausvillage.info/

    just look : http://www.santaclausvillage.info/?page_id=1462

    Alain
    Last edited by Acetronics2; - 5th September 2011 at 17:03.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  12. #12
    Join Date
    Aug 2011
    Location
    Guadalajara, México
    Posts
    28


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Alain, thank you soooo much, you made my day!!!
    It makes me "Return to Innocence" (And not, I'm not affiliated in any way to Enigma)

  13. #13
    johnn34's Avatar
    johnn34 Guest


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    I read all series of candy candy novel and I also watch this cartoon.candy is life loving and cheerful character.

    Japanese cartoon

  14. #14
    jorgepablo's Avatar
    jorgepablo Guest


    Did you find this post helpful? Yes | No

    Default Re: Candy Candy (Old Japanese cartoon) Melody with PIC12F675

    Genial Ivan, gracias por el proyecto, me encanto volver a oir esa cancion, estoy preparandola para un pic 16f84a.
    Supongo que como sos de mexico hablas español.
    ¿La cancion la copiaste a oido?, ¿o utilizaste alguna partitura para hacerlo?, estoy pensando en preparar otras melodias

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts