Another pic10f200 project, the Annoyo!

I had this cool idea for a prank at the office, a device that generate sound every 6 minutes. This device generates 4 different sounds at 6 minute intervals. The idea is that the sounds are short, familiar, difficult to find and infrequent enough to prevent a hunt for the offending noise. This device has been done before and obviously much more professionally by others but it’s fun to make since all you need is 2 caps, a 10f200, a speaker and a battery.

The device itself is dead simple, simply find an old speaker you never use, preferably a small one so that you can drive it from the output pin. Using a small battery like I have there, you could probably let the device run for about 30 days. Here’s the design:

dead simple, once again. Only one output is used on this device, I even disabled MCLR so that there is no extra resistor. Just one cap for decoupling and one cap for producing a larger waveform for the speaker. You can change the cap size if you want, you may want a larger cap for a bit of a smoother wave. So, here’s the pinout and the source code and .hex file

  • GP0,1,3 -> Not connected
  • GP2 (pin 3) -> to speaker

Source and hex: 10f200 annoyo

Anyways, a couple of notes. This program was written with Oshonsoft basic. Also, it could have been written a bit smaller if I tried but as it stands it takes up 253 of 255 bytes available in flash. 🙂

Hope somebody has fun with this!

Personal Projects

Comments (0)


10f200 debouncing and a new compiler

I’ve noticed some people doing search terms for debouncing and I figured I would post my method of debouncing inputs from switches. Some people have a big thing with using caps and resistors and gates with hysteresis but I prefer to simply use a cheap microcontroller because the result is programmable, MCU’s are cheap and there are fewer parts than the usual arrangements. Here is a crude circuit diagram of the debouncer. for this circuit the arrangement is (Input GP3 -> Output GP1)(Input GP2 -> Output GP0)

The problem with some other MCU methods is that people often try checking every 5ms to see if two successive input were high. This is a faulty approach since it can be computationally wasteful and can still produce noise. My approach is as follows:

  1. read the input on a loop
  2. if the input is high, increment a counter up to a certain maximum (say 90)
  3. if the counter goes above a certain amount (say 60) then turn on the output
  4. if the input is low, decrement the counter until it reaches 0
  5. if the counter goes below a certain amount (say 30) then turn off the output
  6. Don’t change the value of the output between 30 and 60

What this does is ensures that there is an area of hysteresis where the noise or bounce of the switch will not generate noise on the output. You can play with the rules to suit your specific need and improve responsiveness or make the output resilient to accidental triggering. This is the reason why for some more important things I have used this method. I have used a pic16f505 for this purpose as well with larger arrays of buttons. Having a programmed method that you can change easily can give you an easy ‘jellybean’ solution for these kinds of problems. Mind you of course when dealing with switches in high noise environments you may need to optoisolate or run TVSs on the switch.

If you’ve read any of my other posts you’ll know that I like the PIC10F200 MCUs simply because of their simplicity and the fact that a lot of people write them off as useless. This design is pretty crude as you can see and that leads me into the topic of the compiler. First,  here is a sample hex file for debouncing - debounce. This hex is programmed to premit a pressed switch to activate after 11ms.

I recently bought a suite of compilers from OshonSoft since I drifted over there out of pure chance. This company is a one man show who sells a variety of BASIC compilers for PIC, Z80 and 8085 processors. I tried the 10f compiler and was immediately impressed with how, for so inexpensively, there was a useful tool for simulation and programming.

I’ve only used the 10f compiler so far but it beats the tar out of PicBASIC Pro, as far as I can tell thus far. Not a lot of frills or gimmicks but it outputs very tight code. Here’s the source for the debouncer pic10f200. You can download a demo version of the 10f simulator at his website.

Well, anyways, that’s my little treatise on the subject. Also, for those of you on a tight budget and just getting into microcontrollers, Oshonsoft might be a good place to buy a compiler that’s reasonably simple.


Comments (0)