We’ll code this project using the Arduino IDE. First, install the Arduino IDE by following this guide https://learn.adafruit.com/adafruit-gemma-m0/arduino-ide-setup
Then, follow this guide on using the Gemma M0 with the Arduino IDE https://learn.adafruit.com/adafruit-gemma-m0/using-with-arduino-ide
Be sure to set up the Arduino Preferences with this URL in the Additional Boards Manager URLs field:
Add the proper boards to the Board Manager for the Gemma M0:
- Adafruit AVR Boards - Includes support for Flora, Gemma, Feather 32u4, Trinket, & Trinket Pro.
- Adafruit SAMD Boards - Includes support for Feather M0, Metro M0, Circuit Playground Express, Gemma M0 and Trinket M0
- Arduino Leonardo & Micro MIDI-USB - This adds MIDI over USB support for the Flora, Feather 32u4, Micro and Leonardo using the arcore project.
The Gemma M0 doesn’t have a traditional AM radio transmitter circuit built in, but it is possible to transmit by using this clever DAC/DMA hack. https://learn.adafruit.com/circuit-playground-express-dac-hacks/overview
In short, it is possible to use the digital-to-analog converter (DAC) in an unintended way by sending it messages very quickly using direct memory access (DMA) — so quickly that the frequency of the analog write pulses actually generate AM radio waveforms!
Check out this page for more info: https://learn.adafruit.com/circuit-playground-express-dac-hacks/transmitting-am-radio
Install the ZeroDMA library as directed here https://learn.adafruit.com/circuit-playground-express-dac-hacks/overview#getting-started
Then, install the AMRadio library as shown here https://learn.adafruit.com/circuit-playground-express-dac-hacks/transmitting-am-radio
To test it all out, and confirm that it's all working, in Arduino open Examples > Adafruit_AMRadio > melody and upload it to your Gemma M0. Clip a wire to the A0 pin to act as an antenna. Hold it close to an AM radio tuned to 540 AM and you’ll hear a familiar song!
Now that we know it’s working, we’ll use a modified version of the original code to send Morse code messages, instead of tone melodies.