PCM.h and pin 3

hi i am using a library called PCM, but my pin 11 is full so PCM.C
I changed the SpeakerPin and the Fast PWM in "void StartPlayBack" to 3, but I took 2 clicks from the buzzer and the sample did not come. what did i do wrong i troubleshoot but i found nothing broken

PCMPin3.zip (26.4 KB)

Changing "speakerPin = 11" to "speakerPin = 3" is not enough. You also have to change "OCR2A" to "OCR2B" and you have to turn on PWM on OC2B instead of OC2A. Change:

  // Do non-inverting PWM on pin OC2A (p.155)
  // On the Arduino this is pin 11.
  TCCR2A = (TCCR2A | _BV(COM2A1)) & ~_BV(COM2A0);
  TCCR2A &= ~(_BV(COM2B1) | _BV(COM2B0));

to:

  // Do non-inverting PWM on pin OC2B (p.155)
  // On the Arduino this is pin 3.
  TCCR2A |= _BV(COM2B1); // Turn on COM2B1
  TCCR2A &= ~_BV(COM2B0); // Turn off COM2B0
  TCCR2A &= ~(_BV(COM2A1) | _BV(COM2A0));

also i try again but, no sound from the buzzer

Does the "playback" example that comes with the PCM library work on Pin 3 after you make the changes? If that works, the problem is probably caused by something else in your sketch.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.