In the MacroPad specs, it says:
8mm Speaker/Buzzer - With Class D amplifier and RC filter, can be used to make simple beeps and sounds effects.
I have tried to find example code of how to implement this into the main macro code.py file for when a key is pressed (or when the encoder switches macros), but can't see any yet.
I tried blending in some of the code from the Simon Says game posted by wilsonRL, but it didn't like me trying to add from adafruit_macropad import MacroPad
Maybe this is spelled out in some other CircuitPython code?
MacroPad Speaker- Any tips on how to use it?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- SolderMask
- Posts: 19
- Joined: Tue Jul 20, 2021 1:50 pm
- dastels
- Posts: 15658
- Joined: Tue Oct 20, 2015 3:22 pm
- RufusVS2020
- Posts: 63
- Joined: Thu Nov 19, 2020 6:31 pm
Re: MacroPad Speaker- Any tips on how to use it?
I got my Adabox today and wanted to drive the speaker. I found two different arduino sources for the demo. One that was shipped had the self-test code in it and a digikey splash screen included, but no speaker code. The other I found had what looked like the start of speaker code that was commented out. I tried to uncomment the code and it would lockup my macropad after the digikey splash came up. I bitbanged the PIN_SPEAKER and PIN_SPEAKER_ENABLE keys and got a sound out of it. I can only conclude that the tone() function is broken in the arduino macropad code. I am going to see if the CircuitPython version fares better.
- SolderMask
- Posts: 19
- Joined: Tue Jul 20, 2021 1:50 pm
Re: MacroPad Speaker- Any tips on how to use it?
Thanks, but it does not appear to play well with the main Macropad code.py file.dastels wrote:See https://learn.adafruit.com/adafruit-mac ... ropad-tone for how to use the speaker.
Dave
I added the macropad mpy file to the lib folder. When I try to add the line adafruit_macropad import MacroPad it breaks.
- SolderMask
- Posts: 19
- Joined: Tue Jul 20, 2021 1:50 pm
Re: MacroPad Speaker- Any tips on how to use it?
Update: Adding from adafruit_macropad import MacroPad does not break it, but when adding the line macropad = MacroPad() it breaks as there must be a conflict with another library.
Opening the adafruit_macropad.mpy library file in Notepad is quite a mess, but what from what I can derive, there are loads of functions available.
I guess I don't know where to really get a solid grip on using CircuitPython. Trying to read the main MacroPad code.py file is very confusing as much of it is not commented.
Feeling lost. Any pointers for novices ('noobs' as the kids call it?) would be great.
Opening the adafruit_macropad.mpy library file in Notepad is quite a mess, but what from what I can derive, there are loads of functions available.
I guess I don't know where to really get a solid grip on using CircuitPython. Trying to read the main MacroPad code.py file is very confusing as much of it is not commented.
Feeling lost. Any pointers for novices ('noobs' as the kids call it?) would be great.
- fishycircuits
- Posts: 46
- Joined: Wed Oct 28, 2020 5:04 pm
Re: MacroPad Speaker- Any tips on how to use it?
This will show you the ropes: https://learn.adafruit.com/adafruit-mac ... on-library
- SolderMask
- Posts: 19
- Joined: Tue Jul 20, 2021 1:50 pm
Re: MacroPad Speaker- Any tips on how to use it?
Thanks fishycircuits, I know you mean well, but this does not address the conflict. Again, when I add these two lines below...fishycircuits wrote:This will show you the ropes: https://learn.adafruit.com/adafruit-mac ... on-library
from adafruit_macropad import MacroPad
macropad = MacroPad()
...to the 'MACROPAD Hotkeys' code.py file, it breaks. (https://learn.adafruit.com/macropad-hotkeys)
The error given in REPL:
Traceback (most recent call last):
File "code.py", line 60, in <module>
ValueError: ENCODER_B in use
I am no code guru (so I love the work of those who design libraries) so I welcome ideas for solutions. Maybe it is not possible to use the MacroPad library in the 'MACROPAD Hotkeys' code.py file. Is there another way to employ the speaker? I'm hoping to have it 'chirp' when switching macro files and when hitting keys- not the noblest of goals, but I'd love to be free to know how to use the MacroPad in all of its glory.
- SolderMask
- Posts: 19
- Joined: Tue Jul 20, 2021 1:50 pm
Re: MacroPad Speaker- Any tips on how to use it?
On another 'note' ;) when trying to learn from the tutorials at:
https://learn.adafruit.com/adafruit-mac ... d-rotation
and
https://learn.adafruit.com/adafruit-mac ... ropad-tone
There must be a glitch somewhere so do these and it will work... (at least it did for me)
1) When you see rainbowio change it to rainbow
2) You will also need to copy rainbow.mpy from the \lib\adafruit_led_animation\animation folder and paste it in \lib.
https://learn.adafruit.com/adafruit-mac ... d-rotation
and
https://learn.adafruit.com/adafruit-mac ... ropad-tone
There must be a glitch somewhere so do these and it will work... (at least it did for me)
1) When you see rainbowio change it to rainbow
2) You will also need to copy rainbow.mpy from the \lib\adafruit_led_animation\animation folder and paste it in \lib.
Please be positive and constructive with your questions and comments.