So there is a little project I am working on with a group and we are using a TFT LCD shield from Seeed Studio (its the v1 of their 2.8" TFT Touchscreen - no SD card). There only output pins we have left are 0 and 1. We would like to hook up a piezo buzzer and play notes based on the touchscreen input. I have seen a little bit of information on getting PWM output to any digital pin, but it looks like it will be difficult. Any suggestions would be much appreciated. We wanted to create a playNote(Note) function to send one of a series of previously defined notes (ie: middle C) to the buzzer.
Suggestions on how to modify the standard code (for sending a tone to the pins that automatically accept pwm output) so that we can send to pin 0 or 1 would be uber appreciated.
You can make a tone on any digital pin... For example, if the pin is high for 1/2 of a millisecond and then low for 1/2 of a millisecond, and you repeat that pattern, you have a 1kHz square wave.
Like anything timing-related, you'll have to make sure the timing doesn't interact badly with your other code.
Another option is an actual "buzzer" (not a transducer) that makes a tone itself when you apply power.
The pin assignments for the LCD Touchscreen shield we are using are as follows::
D0 - Unused.
D1 - Unused.
D2 - LCD data bit 8.
D3 - LCD data bit 9.
D4 - LCD data bit 10.
D5 - LCD data bit 11.
D6 - LCD data bit 12.
D7 - LCD data bit 13.
D8 - LCD data bit 14.
D9 - LCD data bit 15.
D10 - LCD CS pin, active low.
D11 - LCD RS pin.
D12 - LCD WR pin.
D13 - LCD RD pin.
I am reading this as we have 2 digital output (non pwm) pins left that are not being utilized by the LCD. All the code I have seen for playing tones using a piezo buzzer indicate a pwm capable output pin is necessary. Is this really limited to the 6 pre-defined pins or is there a way to re-assign another pin as being pwm capable?