Candy Candy (Old Japanese cartoon) Melody with PIC12F675


Closed Thread
Results 1 to 14 of 14

Hybrid View

  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
    1,033


    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
    1,033


    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
    644


    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
    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

  8. #8
    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

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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