Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC n Tones

Status
Not open for further replies.

AtomSoft

Well-Known Member
I need as much info on tones and how to use a pwm to make em. Im bored lol waiting for other stuff to come in mail for other projects so in the mean time i would love to understand how tones are created through PICs and any info would be great.

Thanks to all again.
 
Do not use an old PC beep speaker for this. If you do some notes will come out as clunkers. :)

I have ported the Above Logic code pointed out by Nigel to work on the Junebug's target using C18. It includes some fixes that extend the ability to use more complex ringtones.

Includes a handful of new songs, may favorite is the AdamsFamily.
 

Attachments

  • ringtone.c
    10.8 KB · Views: 352
Last edited:
Sorry to say 3v0 seems to not work for me...
Maybe you forgot to hookup a speaker ? It needs to go on RB1 or RB4 Pin 7 or 8 on CON8 :)

Are you saying it compiles but you are not getting sound ?

I built it and set breakpoints on the code that toggles the speaker and
it looked like it was working. Also I am fairly sure I used this code
in a private lesson not long ago.

I will hook up a speaker and give it a try.

EDIT: I have moved a lot of things up to school. I do not have any speakers on hand. I will go in and give it a try on saturday.
 
Last edited:
the sound is so faint its not even funny. I tried 3 speakers. They were 1 head phone, the second was a speaker from a Nintendo DS and the third was my surround sound system lol

non played the sound well or loud enough to be worth it.
 
the sound is so faint its not even funny. I tried 3 speakers. They were 1 head phone, the second was a speaker from a Nintendo DS and the third was my surround sound system lol

non played the sound well or loud enough to be worth it.

That is not the same as not working. What are you using for a speaker and capacitor. Do you have the cap such that the + side goes to the PIC ?

This works if you get it setup right. Many people have used various version of it. It should be lould enough to be heard indoors but not what I would call loud.

There is a method called bridging that I learned here a while back. It causes the cone to travel twice as far so it should be twice as loud, maybe more.
A modifed version of interrupt_low can do that. You need to ditch the capacitor and hook one lead of the speaker to RB1 and the other to RB4, they con8 pin 7 & 8. No gound.

Code:
void interrupt_low(void)
{
    if (INTCONbits.T0IF) {
        TMR0L = beat_speed;
        if (TMR0Count) 
           TMR0Count--;
        INTCONbits.T0IF = 0;
    }
    if (PIR1bits.TMR1IF) {
        if (beep) 
        {
          //*********** following 4 lines are changed  ***************/
          if (TONE&0x02)
                TONE=0b00010000;  // RB4 HI RB1 LO
          else
                TONE = 0b00000010;  // RB4 LO RB1 HI
        }
        else      
           TONE = 0;
        TMR1H = preloadTMR1H;
        TMR1L = preloadTMR1L;
        PIR1bits.TMR1IF = 0; /* Clear Flag */
    }
}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top