Maker Pro
Maker Pro

Melody generator

xNihex

Dec 28, 2019
7
Joined
Dec 28, 2019
Messages
7
Best regards,
I need help to create a melody generator using pic16f1939 microcontroller. To be more precise, I need a code that would do this function.
Thanks everyone.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,719
Joined
Nov 17, 2011
Messages
13,719
We will not do your homework for you. What you can expect is support to find a solution in your own way.
Start by telling or showing us what you have achieved so far and where you are stuck.
 

xNihex

Dec 28, 2019
7
Joined
Dec 28, 2019
Messages
7
I have this record in the notes. Would anyone be able to read and digitally record the duration of individual notes and breaks.Or should someone help me with this because I am a music amateur..

Screenshot_1.png
 

bertus

Moderator
Nov 8, 2019
3,321
Joined
Nov 8, 2019
Messages
3,321
Hello,

There are two pieces that are repeated, I marked the start and end with think red arrows.
I also annotated what is played the first and secomd time:

Music_score_annotated.png

Bertus
 

mrgrtt123

Jan 6, 2020
11
Joined
Jan 6, 2020
Messages
11
If this is school work, you should probably pay attention to your class and ask the professor if you are having a hard time reading the samples. There are a lot of tutorials online that you can check to get more ideas regarding this project.
 

bertus

Moderator
Nov 8, 2019
3,321
Joined
Nov 8, 2019
Messages
3,321
Hello,

Looking at the pic you mention, it has only 28k of flash on board:
https://www.microchip.com/wwwproducts/en/PIC16F1939
How would you program a melody in the pic?
You would need information on the pitch and duration of the notes to be played.
You will need to find a way to "store" your melody.

Bertus
 

xNihex

Dec 28, 2019
7
Joined
Dec 28, 2019
Messages
7
I know about that Bertus, butI have no idea how to do it.
Btw I just started working with pic microcontroller.
In fact, I'm also an amateur in programming.. :)
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,719
Joined
Nov 17, 2011
Messages
13,719
There is at least one library to generate sound snippets (tones) of defined frequency and duration from a pic µc and a discussion on the topic here.
You'll have to translate the notes of the sheet into a set of frequency/duration pairs (e.g. in the form of an array) and loop through them in your program, calling each tone for the specified duration (duration being a function of the Tempo and the Note Value)
 
Top