ECE Mini Project : Playing Music with 8051 Microcontroller

Published on Aug 25 2010 // Electronics, Projects

Warning: Missing argument 2 for wpdb::prepare(), called in /home3/nithish/public_html/btechzone.com/wp-content/plugins/sharebar/sharebar.php on line 112 and defined in /home3/nithish/public_html/btechzone.com/wp-includes/wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in /home3/nithish/public_html/btechzone.com/wp-content/plugins/sharebar/sharebar.php on line 124 and defined in /home3/nithish/public_html/btechzone.com/wp-includes/wp-db.php on line 990
  • Sharebar

Do you know our 8051 microcontroller can play music tones, here’s an sample. Undecided

The circuit & code given here will play the music for “wishes you to be safe”

The IC LM386 is just an audio amplier, you can use any audio amplifier circuits.

More projects with music to be coming soon here

CIRCUIT DIAGRAM

Download the asm and hex code from below

ASSEMBLY CODE:

[code:asm]ORG 0000H

LJMP START
ORG 000BH
INC 20H; interruption of Counter 1
MOV TH0, #0D8H
MOV TL0, #0EFH; 12M crystal to create a 10 ms interruption
RETI
START:
MOV SP, #50H
MOV TH0, #0D8H
MOV TL0, #0EFH
MOV TMOD, #01H
MOV IE, #82H
MUSIC0:
NOP
MOV DPTR, #DAT; first address of the table to send DPTR
MOV 20H, #00H; interrupt counter
MOV B, #00H; table number
MUSIC1:
NOP
CLR A
MOVC A, @A+DPTR; access code from look-up table
JZ END0; is 00H, then the end of music
CJNE A,#0FFH, MUSIC5
LJMP MUSIC3
MUSIC5:
NOP
MOV R6, A
INC DPTR
MOV A, B
MOVC A,@A+DPTR; access beat code and send to R7
MOV R7, A
SETB TR0; start counting
MUSIC2:
NOP
CPL P3.0
MOV A, R6
MOV R3, A
LCALL DEL
MOV A, R7
CJNE A,20H,MUSIC2; interrupt counter (20H) = R7
; Range, then continue to cycle
MOV 20H,#00H
INC DPTR
; INC B
LJMP MUSIC1
MUSIC3:
NOP
CLR TR0; ending of 100 ms
MOV R2,#0DH
MUSIC4:
NOP
MOV R3,#0FFH
LCALL DEL
DJNZ R2, MUSIC4
INC DPTR
LJMP MUSIC1
END0:
NOP
MOV R2,#64H; song ended after 1 seconds delay
MUSIC6:
MOV R3,#00H
LCALL DEL
DJNZ R2, MUSIC6
LJMP MUSIC0
DEL:
NOP
DEL3:
MOV R4,#02H
DEL4:
NOP
DJNZ R4,DEL4
NOP
DJNZ R3,DEL3
RET
NOP
DAT:
db 26h, 20h, 20h, 20h, 20h, 20h, 26h, 10h, 20h, 10h, 20h, 80h, 26h, 20h, 30h, 20h
db 30h, 20h, 39h, 10h, 30h, 10h, 30h, 80h, 26h, 20h, 20h, 20h, 20h, 20h, 1ch, 20h
db 20h, 80h, 2bh, 20h, 26h, 20h, 20h, 20h, 2bh, 10h, 26h, 10h, 2bh, 80h, 26h, 20h
db 30h, 20h, 30h, 20h, 39h, 10h, 26h, 10h, 26h, 60h, 40h, 10h, 39h, 10h, 26h, 20h
db 30h, 20h, 30h, 20h, 39h, 10h, 26h, 10h, 26h, 80h, 26h, 20h, 2bh, 10h, 2bh, 10h
db 2bh, 20h, 30h, 10h, 39h, 10h, 26h, 10h, 2bh, 10h, 2bh, 20h, 2bh, 40h, 40h, 20h
db 20h, 10h, 20h, 10h, 2bh, 10h, 26h, 30h, 30h, 80h, 18h, 20h, 18h, 20h, 26h, 20h
db 20h, 20h, 20h, 40h, 26h, 20h, 2bh, 20h, 30h, 20h, 30h, 20h, 1ch, 20h, 20h, 20h
db 20h, 80h, 1ch, 20h, 1ch, 20h, 1ch, 20h, 30h, 20h, 30h, 60h, 39h, 10h, 30h, 10h
db 20h, 20h, 2bh, 10h, 26h, 10h, 2bh, 10h, 26h, 10h, 26h, 10h, 2bh, 10h, 2bh, 80h
db 18h, 20h, 18h, 20h, 26h, 20h, 20h, 20h, 20h, 60h, 26h, 10h, 2bh, 20h, 30h, 20h
db 30h, 20h, 1ch, 20h, 20h, 20h, 20h, 80h, 26h, 20h, 30h, 10h, 30h, 10h, 30h, 20h
db 39h, 20h, 26h, 10h, 2bh, 10h, 2bh, 20h, 2bh, 40h, 40h, 10h, 40h, 10h, 20h, 10h
db 20h, 10h, 2bh, 10h, 26h, 30h, 30h, 80h, 00H

END[/code]

18 Comments

  1. namitha says:

    can you give me more explanation about the programme so it may help me to understand more

  2. devu says:

    super presentation

  3. Tanzila says:

    Can you please explain how you got all those hexadecimal numbers at the end of the program? If I want to play a different tune using this program, what are the changes that i will have to make? Can you please tell me how i can convert the frequency notes of a song into hex numbers? I’m sorry for asking so many questions, but i’m really lost! Someone plz help!

  4. Tanisha says:

    hi everybody!!!i really need help badly!!i have d same question as tanzila.can you please explain how to convert music notes or tunes into hex codes?the numbers at the end of the program represent the song being played…my question is ..how did you figure them out?it will be really really helpful if you can provide the answer.its very urgent!!!thanks!

  5. sruthi says:

    please explain me the code at the end of program.how can we play a different tune

  6. madhu says:

    explain the code at the end of the program.

  7. shruthi says:

    please provide the explanation of the end codes n for different tunes

  8. s says:

    please explain the code.

  9. AMAR says:

    give mi this project ckt diagram &program in pdf format

  10. g.mallesh says:

    send me full explanation of this project and full project file.

  11. priya says:

    pleas give me this program and ckt diagram in pdf format and also explain the code how can we modify the code for different tunes….
    it is really important and urgent please reply

  12. kapil says:

    how to program this assembly code into microcontroller at89s52

  13. anklet says:

    plz send the details regarding this project including circuit diagram and its full description

  14. shyama says:

    how to program this assembly code into microcontroller 89s52? plz explain the code complty. how can it be used for different tunes????????????? plz reply fast..

  15. wel wisher says:

    the no.s given in the look up table r the values of count to be loaded.
    if u r unable to understand it, plz refer ‘subrata ghoshal’- a book based on applications of 8051 in robotics, page no. 183.

    basically, a song is consist of notes of specific frequency. to generate that frequency some specific count is loaded that is given in look up table.for this you can develope ur own logic.

    if u want to generate diff. songs, first you have to find out the sequence of nodes and their amplitude i.e. pitch and octave.

  16. mohan raj says:

    can u send this abstract 2 me pls bcoz this very helpful to my mini project

  17. Horatio says:

    Music on base 8051 MCU? Boys – here: http://forum.mcontrollers.com/viewtopic.php?t=1179 – It is project sound generator, version 1,08. Author “Hannibal” uses 8051 core / 16MHz. Application generates four channels 1-bit music. On chip is 14 songs. Try it, very nice….

  18. moon says:

    can you pls send me the detail pdf about this code and projects

Leave a comment