Step 10Program the microcontroller.
The code I used can probably be converted to a more universal programming language and modified to fit your needs. Essentially, one potentiometer controls the frequency of the note and the other controls the duration of the note.
For this task the PIC chip is like using a machine to kill a mosquito. You probably can get the same effect with a 555 chip or two, but I had the PIC chip on hand at the time and felt like using it.
It is as follows:
CPU = 16F877
MHZ = 20
CONFIG 16254
screeching var word
longing var word
' sets variables
main:
HIGH B1
RCTIME B1,1,screeching
' note frequency potentiometer reading
HIGH B2,1,longing
RCTIME B2,1,longing
' note duration potentiometer reading
screeching = screeching * 2
' increases the notes frequency range
longing = longing / 12
' decreases notes duration to about 4 second maximum
if longing < 1 then
longing = 1
endif
' prevents 1 or 0 from being divided by 12 and crashing the program
FREQOUT B0,longing,screeching
' sound output on pin B0
goto main
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|





















































