acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

AFSK_Tone.ino (2157B)

      1 /*
      2    RadioLib AFSK Example
      3 
      4    This example shows hot to send audio FSK tones
      5    using SX1278's FSK modem.
      6 
      7    Other modules that can be used for AFSK:
      8     - SX127x/RFM9x
      9     - RF69
     10     - SX1231
     11     - CC1101
     12     - Si443x/RFM2x
     13 
     14    For default module settings, see the wiki page
     15    https://github.com/jgromes/RadioLib/wiki/Default-configuration
     16 
     17    For full API reference, see the GitHub Pages
     18    https://jgromes.github.io/RadioLib/
     19 */
     20 
     21 // include the library
     22 #include <RadioLib.h>
     23 
     24 // SX1278 has the following connections:
     25 // NSS pin:   10
     26 // DIO0 pin:  2
     27 // RESET pin: 9
     28 // DIO1 pin:  3
     29 SX1278 radio = new Module(10, 2, 9, 3);
     30 
     31 // create AFSK client instance using the FSK module
     32 // this requires connection to the module direct
     33 // input pin, here connected to Arduino pin 5
     34 // SX127x/RFM9x:  DIO2
     35 // RF69:          DIO2
     36 // SX1231:        DIO2
     37 // CC1101:        GDO2
     38 // Si443x/RFM2x:  GPIO
     39 AFSKClient audio(&radio, 5);
     40 
     41 void setup() {
     42   Serial.begin(9600);
     43 
     44   // initialize SX1278 with default settings
     45   Serial.print(F("[SX1278] Initializing ... "));
     46   int state = radio.beginFSK();
     47 
     48   // when using one of the non-LoRa modules for AFSK
     49   // (RF69, CC1101, Si4432 etc.), use the basic begin() method
     50   // int state = radio.begin();
     51 
     52   if(state == RADIOLIB_ERR_NONE) {
     53     Serial.println(F("success!"));
     54   } else {
     55     Serial.print(F("failed, code "));
     56     Serial.println(state);
     57     while(true);
     58   }
     59 
     60   // initialize AFSK client
     61   Serial.print(F("[AFSK] Initializing ... "));
     62   state = audio.begin();
     63   if(state == RADIOLIB_ERR_NONE) {
     64     Serial.println(F("success!"));
     65   } else {
     66     Serial.print(F("failed, code "));
     67     Serial.println(state);
     68     while(true);
     69   }
     70 }
     71 
     72 void loop() {
     73   // AFSKClient can be used to transmit tones,
     74   // same as Arduino tone() function
     75   
     76   // 400 Hz tone
     77   Serial.print(F("[AFSK] 400 Hz tone ... "));
     78   audio.tone(400);
     79   delay(1000);
     80 
     81   // silence
     82   Serial.println(F("done!"));
     83   audio.noTone();
     84   delay(1000);
     85 
     86   // AFSKClient can also be used to transmit HAM-friendly
     87   // RTTY, Morse code, Hellschreiber, SSTV and AX.25.
     88   // Details on how to use AFSK are in the example
     89   // folders for each of the above modes.
     90 }