Caja musical PIC16F84A

Muy bueno, lo voy a probar. Y para reproducir el sonido que me conviene usar?

el siguiente circuito :)

picture.php


claro que al PIC le colocas su respectivo oscilador y la salida dependera de a donde la dirijas en los pines
 
mm no encuentro mayor diferencia que el microcontrolador..
sera por mi computadora?.. la simulacion en proteus va lenta "due exesive CPU load"

sera esto el micro controlador?

Código:
define xtal 4
device 16f84A
'tempo = 150
'60/150 = duracion de una nota negra
'redonda = 1600
'blanca = 800
'negra = 400
'corchea = 200
'semi corchea = 100
'Ejemplo del comando
'FREQOUT portb.0, 2000, 7200 sacar una frecuencia 
'de 7,2 Khz durante 2 segundos por el Puerto B.0

start:
'primer compas
Freqout portb.0, 400, 659
Freqout portb.0, 200, 493
Freqout portb.0, 200, 523
Freqout portb.0, 400, 587
Freqout portb.0, 200, 523
Freqout portb.0, 200, 493
'segundo compas
Freqout portb.0, 400, 440
Freqout portb.0, 200, 440
Freqout portb.0, 200, 523
Freqout portb.0, 400, 659
Freqout portb.0, 200, 587
Freqout portb.0, 200, 523
'tercer compas
Freqout portb.0, 400, 493
Freqout portb.0, 200, 493
Freqout portb.0, 200, 523
Freqout portb.0, 400, 587
Freqout portb.0, 400, 659
'cuarto compas
Freqout portb.0, 200, 523
Freqout portb.0, 400, 440
Freqout portb.0, 800, 440
'quito compas
pause 200
Freqout portb.0, 400, 587
Freqout portb.0, 200, 698
Freqout portb.0, 400, 880
Freqout portb.0, 200, 783
Freqout portb.0, 200, 698
'sexto compas
Freqout portb.0, 400, 659
pause 500
Freqout portb.0, 200, 523
Freqout portb.0, 400, 659
Freqout portb.0, 200, 587
Freqout portb.0, 200, 523
'tercer compas
Freqout portb.0, 400, 493
Freqout portb.0, 200, 493
Freqout portb.0, 200, 523
Freqout portb.0, 400, 587
Freqout portb.0, 400, 659
'cuarto compas
Freqout portb.0, 200, 523
Freqout portb.0, 400, 440
Freqout portb.0, 800, 440

                                
END

las pausas son los silencios, lo divido en compases para mejor lectura, no quise mandarme a escribir todas las octavas con el var y




ya probe tu codigo y funciona bien pero aun no entiendo como es que sacas esto

Freqout portb.0, 800, 440

si alguien me podria dar alguna ayuda se lo agradeceria mucho
es que quiero aprender para poder ponerle mas melodias a mi pic grax de antemano
 
ya probe tu codigo y funciona bien pero aun no entiendo como es que sacas esto

Freqout portb.0, 800, 440

si alguien me podria dar alguna ayuda se lo agradeceria mucho
es que quiero aprender para poder ponerle mas melodias a mi pic grax de antemano


Es una instruccion de PBP (Pic Basic Pro)

http://www.todopic.com.ar/pbp_sp.html#freqout
 
bueno creo que no me exprese bien si se que son instrucciones lo que no entiendo es como hizo para saber que nota era la que representa ese numero(800, 440)ya se que uno es el tiempo y el otro es la frecuencia pero quisiera saber como sacar la frecuencia de una cancion o melodia????????

me dicen que tengo que utilizar la instruccion sound dicen que es mejor que me podrian aconsejar la verdad recien estoy comenzando... con esto del picbasic
graciasss!!!!!!!!!!!!
 
Última edición por un moderador:
La frecuencia esta dada por la nota... 440Hz corresponde a la nota "LA", aqui te dejo las frecuencias de cada nota para cada octava....

Primera octava:
---------------
Do 1: 65,406
Do# 1: 69,296
Re 1: 73,416
Re# 1: 77,782
Mi 1: 82,407
Fa 1: 87,307
Fa# 1: 92,499
Sol 1: 97,999
Sol#1: 103,826
La 1: 110
La# 1: 116,541
Si 1: 123,471

Segunda octava:
---------------
Do 2: 130,813
Do# 2: 138,591
Re 2: 146,832
Re# 2: 155,563
Mi 2: 164,814
Fa 2: 174,614
Fa# 2: 184,997
Sol 2: 195,998
Sol#2: 207,652
La 2: 220
La# 2: 233,082
Si 2: 246,942

Tercera octava:
---------------
Do 3: 261,626
Do# 3: 277,183
Re 3: 293,665
Re# 3: 311,127
Mi 3: 329,628
Fa 3: 349,228
Fa# 3: 369,994
Sol 3: 391,995
Sol#3: 415,305
La 3: 440
La# 3: 466,164
Si 3: 493,883

Cuarta octava:
---------------
Do 4: 523,251
Do# 4: 554,365
Re 4: 587,33
Re# 4: 622,254
Mi 4: 659,255
Fa 4: 698,456
Fa# 4: 739,989
Sol 4: 783,991
Sol#4: 830,609
La 4: 880
La# 4: 932,328
Si 4: 987,767

Quinta octava:
---------------
Do 5: 1046,502
Do# 5: 1108,731
Re 5: 1174,659
Re# 5: 1244,508
Mi 5: 1318,51
Fa 5: 1396,913
Fa# 5: 1479,978
Sol 5: 1567,982
Sol#5: 1661,219
La 5: 1760
La# 5: 1864,655
Si 5: 1975,533

Sexta octava:
---------------
Do 6: 2093,005
Do# 6: 2217,461
Re 6: 2349,318
Re# 6: 2489,016
Mi 6: 2637,02
Fa 6: 2793,826
Fa# 6: 2959,955
Sol 6: 3135,963
Sol#6: 3322,438
La 6: 3520
La# 6: 3729,31
Si 6: 3951,066

Septima octava:
---------------
Do 7: 4186,009
Do# 7: 4434,922
Re 7: 4698,636
Re# 7: 4978,032
Mi 7: 5274,041
Fa 7: 5587,652
Fa# 7: 5919,911
Sol 7: 6271,927
Sol#7: 6644,875
La 7: 7040
La# 7: 7458,62
Si 7: 7902,133

Octava octava:
(valga la redundancia :)
---------------
Do 8: 8372,018
Do# 8: 8869,844
Re 8: 9397,273
Re# 8: 9956,063
Mi 8: 10548,082
Fa 8: 11175,303
Fa# 8: 11839,822
Sol 8: 12543,854
Sol#8: 13289,75
La 8: 14080
La# 8: 14917,24
Si 8: 15804,266
 
ya corri el programa en mplab y si me lo compila lo que tengo duda es: que es lo que conectas una bocina o un buzzer y la otra duda es en donde lo conectas, yo etoy usando un pic16f877a que es basicamente de la misma famila pero no se donde esta la salida y como controlas los sonidos gracias
 
ya corri el programa en mplab y si me lo compila lo que tengo duda es: que es lo que conectas una bocina o un buzzer y la otra duda es en donde lo conectas, yo etoy usando un pic16f877a que es basicamente de la misma famila pero no se donde esta la salida y como controlas los sonidos gracias

pues en tu programacion tienes q ver por q pin estas mandandole la frecuencia pues seria bueno q subieras tu programa
 
ola tengo un problema al momento de compilar el archibo
no se q pasa me sale un error en el basic ..si pudieran ayudarme
porq lo encuentro muy interesante este tema
 
es el que an posteado aca este es
Código:
'****************************************************************
'*  Name    :  Programa de Producción de musica 2010: Tema 1    *
'*  Author  : [mecatrodatos                                     *
'*  Notice  : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 28/07/2010                                        *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************

'-----------Inicializacion ---------

    define OSC 20           ' Establece la frecuencia de operación del microcontrolador
                            'A 20 MHz.
    TRISB = %11111000          ' Configura RB0 - 3 de PORTB como salida
    
    PORTB = %00000000        ' Establece todos los pines en PORTB en Bajo (0 V).          



' La variable "x" representa la octava nota. La longitud de tiempo que la
' corchea (x) es detereminada por el valor fijado en 200.
' Un cuarto de nota es dos veces una corchea o 2x.

    x var Word 
    
' Estas son las constantes que se utiliza para declarar las frecuencias Como señala.
'Por ejemplo los grupos de autoayuda representa Super G de alta que tiene una frecuencia de 1568 Hz.
    
    shg con  1568
    shef con 1244
    shc con  1046
    shbf con 932
    shaf con 830
    hg con   784
    hf con   698
    hef con  622
    hd con   587
    hc con   523
    hbf con  466
    haf con  415
    g con    392
    f con    349
    ef con   311
    d con    293
    c con    261
    bf con   233
    af con   208
    lg con   196
    lf con   174
    lef con  155
    ld con   146
    lc con   130
    lbf con  116
    laf con  103
    slg con  98
    slf con  87
    slef con 78
    sld con  73
    slc con  65
    
'-------------programa principal------------    
    
    x = 200             ' Una nota de sesiones (x) será de 200 ms largo.
      
  Pause 1000            ' Pausa 1000 ms antes de iniciar la generación de tonos.
    
' linea 1  

  FreqOut 1, x, g       ' Usamos FreqOut Para generar un tono. 1 representa
'pin de salida RB1 en el PIC16F88. "X" simboliza la
'corchea. "G" se define como la frequecy 392 Hz.
                        
  FreqOut 1, x, f       
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, ef
  FreqOut 1, x, c
  FreqOut 1, 4*x, ef
  FreqOut 1, 4*x, d
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, ef
  FreqOut 1, x, c
  FreqOut 1, 4*x, ef
  FreqOut 1, 4*x, d
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, g
  FreqOut 1, x, f
  
 'linea 2
 
  FreqOut 1, x, ef
  FreqOut 1, x, c
  FreqOut 1, 3*x, d
  FreqOut 1, x, ef
  FreqOut 1, x, d
  FreqOut 1, x, c
  FreqOut 1, x, bf
  FreqOut 1, x, af
  FreqOut 1, 8*x, ef
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hef
  FreqOut 1, x, hc
  FreqOut 1, 2*x, hef
  
  'linea 3
  
  FreqOut 1, 2*x, hef
  FreqOut 1, 4*x, hd
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hef
  FreqOut 1, x, hc
  FreqOut 1, 4*x, hef             
  FreqOut 1, 4*x, hd                         
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hef
  FreqOut 1, x, hc
  FreqOut 1, 2*x, hd
  FreqOut 1, x, hef
  FreqOut 1, x, hd
  FreqOut 1, x, hc
  
  'linea 4
  
  FreqOut 1, x, hbf
  FreqOut 1, x, haf
  FreqOut 1, 9*x, hef
  FreqOut 1, 4*x, 0  
  FreqOut 1, x, ef
  FreqOut 1, x, d
  FreqOut 1, x, c
  FreqOut 1, x, bf
  FreqOut 1, x, c
  FreqOut 1, x, d 
  FreqOut 1, 2*x, lg 
  FreqOut 1, x, ef
  FreqOut 1, x, d
  FreqOut 1, x, c
  FreqOut 1, x, bf
  FreqOut 1, 2*x, c
  FreqOut 1, x, ef
  FreqOut 1, x, d
  FreqOut 1, x, c
  FreqOut 1, x, bf
  FreqOut 1, x, c
  FreqOut 1, x, d
  FreqOut 1, 2*x, lg 
  FreqOut 1, x, ef
  FreqOut 1, x, d
  
  'linea 5 
  
  FreqOut 1, x, c
  FreqOut 1, x, bf
  FreqOut 1, 2*x, c 
  FreqOut 1, x, ef
  FreqOut 1, x, d
  FreqOut 1, x, c
  FreqOut 1, x, bf
  FreqOut 1, x, c
  FreqOut 1, x, d
  FreqOut 1, 2*x, lg
  FreqOut 1, x, ef
  FreqOut 1, x, d
  FreqOut 1, x, c
  FreqOut 1, x, d
  FreqOut 1, 2*x, c
  FreqOut 1, x, hef
  FreqOut 1, x, hd
  FreqOut 1, x, hc
  FreqOut 1, x, hbf
  FreqOut 1, x, hc
  FreqOut 1, x, hd
  FreqOut 1, 2*x, g
  FreqOut 1, x, hef
  FreqOut 1, x, hd
  FreqOut 1, x, hc
  FreqOut 1, x, hbf
  FreqOut 1, 2*x, hc
  
  'linea 6
  
  FreqOut 1, x, hef
  FreqOut 1, x, hd
  FreqOut 1, x, hc
  FreqOut 1, x, hbf
  FreqOut 1, x, hc
  FreqOut 1, x, hd
  FreqOut 1, 2*x, g
  FreqOut 1, x, hef
  FreqOut 1, x, hd
  FreqOut 1, x, hc
  FreqOut 1, x, hbf
  FreqOut 1, 2*x, hc
  FreqOut 1, x, hef
  FreqOut 1, x, hd
  FreqOut 1, x, hc
  FreqOut 1, x, hbf
  FreqOut 1, x, hc
  FreqOut 1, x, hd
  FreqOut 1, 2*x, g
  FreqOut 1, x, hef
  FreqOut 1, x, hd
  FreqOut 1, x, hc
  FreqOut 1, x, hd
  FreqOut 1, 2*x, hc
  FreqOut 1, 2*x, hg
  FreqOut 1, 2*x, shC
  
  'linea 7
  
  FreqOut 1, 2*x, shef
  FreqOut 1, 4*x, shg
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, ef
  FreqOut 1, x, c
  FreqOut 1, 4*x, ef
  FreqOut 1, 4*x, d
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, ef
  FreqOut 1, x, c
  FreqOut 1, 4*x, ef
  FreqOut 1, 4*x, d
  
  'linea 8
  
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, g
  FreqOut 1, x, f
  FreqOut 1, x, ef
  FreqOut 1, x, c
  FreqOut 1, 3*x, d
  FreqOut 1, x, ef
  FreqOut 1, x, d
  FreqOut 1, x, c
  FreqOut 1, x, bf
  FreqOut 1, x, af
  FreqOut 1, 8*x, ef
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hef
  FreqOut 1, x, hc
  FreqOut 1, 2*x, hef
  
  'linea 9
  
  FreqOut 1, 2*x, hef
  FreqOut 1, 4*x, hd
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hef
  FreqOut 1, x, hc
  FreqOut 1, 4*x, hef             
  FreqOut 1, 4*x, hd                         
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hg
  FreqOut 1, x, hf
  FreqOut 1, x, hef
  FreqOut 1, x, hc
  FreqOut 1, 2*x, hd
  FreqOut 1, x, hef
  FreqOut 1, x, hd
  FreqOut 1, x, hc
  FreqOut 1, x, hbf
  FreqOut 1, x, haf
  FreqOut 1, 6*x, hef             
  End
 
Última edición por un moderador:
Atrás
Arriba