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.

Junebug help??

Status
Not open for further replies.
It's real good I was playing with the timer and events which made two tones
was going to try the swordfish user module. But then Mike post his random number generator code it a lot easier then the module.
 
You should have DIP switches 1 to 3 on and the sound will come out of A3 - not B3. To make it B3 change,
Code:
Dim Speaker As PORTA.3
Dim SpeakerTris As TRISA.3
To,
Code:
Dim Speaker As PORT[COLOR="red"]B[/COLOR].3
Dim SpeakerTris As TRIS[COLOR="Red"]B[/COLOR].3

Mike.
 
I changed the code

as per post but?
am I supposed to release from reset or ??
using mplab to program or do I use pickit2 or does it matter?
 
tried just using the swordfish

, hit F10 and now it works
not very loud
perhaps adding an amp??
 
MrDEB I think that will run them off just hook your pir to Rb0 Mike code change real good I tested it with this add a toggle to his code just to see how it would sound with the pir hooked there
Code:
While(TRUE)             //repeat forever
    toggle (portb.0)
    delayms (250)
    If PORTB.0=0 Then       //if button 1 pressed
        For i = 1 To 10     //play 10 tones
            Tone=Rand(5)    //each tone is random frequency
            DelayMS(250)    //and for 0.25 seconds
        Next                //end for loop
    Else                    //otherwise
        Tone=5              //silence
        i=Rand(255)         //make rand more random
    EndIf                   //end if condition
Wend                    //end of while loop

End
 
speaker too small??

bought a rat shack speaker #273-092
a 1 1/8" (29mm)diameter speaker
.10W rated input
maxium input .20W
 
, hit F10 and now it works
not very loud
perhaps adding an amp??

Yes, the pic can't supply much power so you will need some amplification. Maybe one of the analogue guys can advise?

@Burt,
No need to add a toggle, just press button 1 to hear the awful sound.

Mike.
 
Good headphones can put out more power than that.
 
I say a deer could hear it at a 100 yards or more you could use a 9 volt to drive the speaker
 
be80be that code is already in

the code Mike posted (pretty sure all is there)
I press sw 1 on juney (RB0) and little juney plays notes
not very loud but sounds pretty random
i'll figure out how to make it longer, perhaps 3x longer as well as louder for sure.
All them deer may be hard of hearing, yea right
 
@Burt,
No need to add a toggle, just press button 1 to hear the awful sound.
I don't have a junebug I was using my pickit2 and a 18f1220 with a speaker
hooked to it like showed MrDEB. So just toggled it to see how it would sound with the PIR going off on portb.0 Thanks for the code Mike. The number part will come in handy.
 
.1 watt at 5 volts is only 20ma's a PIC pin should be able to do that.
 
Louder I can't help with but the rest I can,

For more notes change to 10 in this line,
Code:
        For i = 1 To 10     //play 10 tones

For each note to last longer change this line,
Code:
            DelayMS(250)    //and for 0.25 seconds
The 250 is in milli seconds and so equals 0.25 seconds. To make each tone 1 second long change the 250 to 1000.

The total time will be the number of notes times the length.

Mike.
 
My wife can hear it and she was watching judge Judy three rooms over from me wanted to know what the H is going off in the house. lol He should be getting all his speaker can handle. If he driving it like I showed him
 
Last edited:
something agnt right??

I changed the
For i = 1 To 10 //play 10 tones
to i=1-20
nothing comes out of speaker
changed back to 10 and it then works
changed DelayMS(250) //and for 0.25 seconds
DelayMS(1000) //and for 1.00 seconds
nada, no sound
changed back to 250 and it works
summthung not right??
 
CAUTION be80be

you wife is deer (dear)
LOL
what is the assumed wattage of this setup using the 2n2222, 10K resistor at 5v
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top