I soldered a buzzer to my custom I/O board so that it was hard-wired to A7. It took me a while to figure out how to get it working since the information in config.h is non-intuitive (no, you don't need pilot lamp enabled to use the buzzer). Here's what you need:
Code: Select all
#define BUZZER
#define OVERRIDE_BUZZERPIN_PINMODE pinMode (A7, OUTPUT); // use A7 instead of d8
#define OVERRIDE_BUZZERPIN_ON PORTF |= 1<<7;
#define OVERRIDE_BUZZERPIN_OFF PORTF &= ~(1<<7);
The trick is that on ATMega2560 boards (like the Crius All-In-One-Pro) the analog pins (A0-A7) are actually PORTF, not PORTB. Also, the number next to your PORTF #define lines need to match the port number. So A7 needs to use '1<<7', A5 would be '1<<5' and so on.
Also, for those googling "what buzzer should I use?" I used, 5V Continuous Sound Piezo Buzzers that have the little, "remove seal after washing" sticker. They weigh ~1.6g each and are really quite loud.
No, I did not use a resistor when wiring them up directly to A7. If I burn it out, well, I only paid ~$3 for five of them (shipped).
EDIT 2014-01-26: I just realized the eBay link I used only works for me so I've replaced it with an Amazon link to what appears to be the exact same product (at pretty much the same price).