Hi all!
I'm working on a project, where i'm using the toneAC.h library to drive a piezo. It works perfectly when i use the pins 9 and 10 as described in the library. However since we in the project need to use pin 10 for another component i'm trying to use other pins. To do so i opened the .h file in the library and tried to get an understanding of what's going on. As far as i understand currently it says:
#if defined (__AVR_ATmega32U4__) || defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
#define PWMT1AMASK DDB5
#define PWMT1BMASK DDB6
#define PWMT1DREG DDRB
#define PWMT1PORT PORTB
#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__)
#define PWMT1AMASK DDD4
#define PWMT1BMASK DDD5
#define PWMT1DREG DDRD
#define PWMT1PORT PORTD
#else
#define PWMT1AMASK DDB1
#define PWMT1BMASK DDB2
#define PWMT1DREG DDRB
#define PWMT1PORT PORTB
#endif
Where the DDB1 and DDB2 in the final 'else' statement refers to pin 9 and 10 based on this picture:
My intuition then tells me, that based on
i should change
#define PWMT1AMASK DDB1
#define PWMT1BMASK DDB2
#define PWMT1DREG DDRB
#define PWMT1PORT PORTB
into
#define PWMT1AMASK DDD3
#define PWMT1BMASK DDD5
#define PWMT1DREG DDRD
#define PWMT1PORT PORTD
In order to change from pin 9 and 10 into 3 and 5.
However this doesn't work, and the piezo doesn't work with this approach.
Does anyone have an idea on what i'm doing wrong?
I'm not a big expert! Rather new to arduino and this kind of programming.
Thanks a lot in advance!