### Setup Web Server for OTA Updates Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/ota.md This code is required in the setup() function to enable OTA updates via a web browser. It initializes MDNS, sets up the HTTP updater, starts the web server, and adds the HTTP service to MDNS. ```cpp MDNS.begin(host); httpUpdater.setup(&httpServer); httpServer.begin(); MDNS.addService("http", "tcp", 80); ``` -------------------------------- ### Get BLE Server Object and Start Advertising Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/ble.md Obtain a pointer to the global BLE server object and start advertising its services. This is done after initializing the BT stack. ```cpp #include void setup() { BLE.begin(); auto server = BLE.server(); // Get pointer to single global server object // ... create a BLEService with BLECharacteristics somehow... server->addService(...); // Add the service we just made to the object server->startAdvertising(); // Tell the world about it! } ``` -------------------------------- ### begin() Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/wifiserver.md Starts the WiFi server to listen for incoming connections on a specified port. ```APIDOC ## begin() ### Description Starts the WiFi server to listen for incoming connections on a specified port. ### Method `begin()` ### Endpoint N/A ### Parameters None explicitly documented for this method signature in the provided text. ### Request Example ```cpp server.begin(); ``` ### Response N/A ``` -------------------------------- ### Example: Custom SPI Pinout for SD Library Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/pins.md Demonstrates how to reconfigure SPI pins for a library like SD that uses the SPI library, by calling the respective set methods in setup() before initializing the library. ```cpp void setup() { SPI.setRX(4); SPI.setTX(7); SPI.setSCK(6); SPI.setCS(5); SD.begin(5); } ``` -------------------------------- ### Start OpenOCD for Picoprobe Debugging Source: https://github.com/earlephilhower/arduino-pico/blob/master/README.md Use these commands to start OpenOCD with the appropriate configuration file for Picoprobe debugging. These commands should be run from the `git` installation directory. ```bash ./system/openocd/bin/openocd -f ./lib/rp2040/picoprobe_cmsis_dap.tcl ``` ```bash ./system/openocd/bin/openocd -f ./lib/rp2350/picoprobe_cmsis_dap.tcl ``` -------------------------------- ### Write Profiling Data with Semihosting Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/profiling.md This example demonstrates how to write profiling data to a 'gmon.out' file using semihosting after completing work in the setup function. Ensure Semihosting is enabled and the debugger is attached. ```cpp #include void setup() { SerialSemi.printf("BEGIN\n"); do_some_work_that_takes_a_long_time_with_many_function_calls(); // Do lots of other work... // Now all done... SerialSemi.printf("Writing GMON.OUT\n"); SemiFS.begin(); File gmon = SemiFS.open("gmon.out", "w"); rp2040.writeProfiling(&gmon); gmon.close(); SerialSemi.printf("END\n"); } void loop() {} ``` -------------------------------- ### begin() Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/wifiudp.md Starts the WiFiUDP client. This method is used to initiate UDP communication. ```APIDOC ## begin() ### Description Starts the WiFiUDP client, enabling it to send and receive UDP packets. ### Method `WiFiUDP.begin()` ### Endpoint N/A (Method Call) ### Parameters None ``` -------------------------------- ### Install Arduino Pico via GIT (Windows) Source: https://github.com/earlephilhower/arduino-pico/blob/master/README.md Installs the latest development version of the Arduino Pico board support by cloning the repository and updating submodules. Requires Python to be installed. Ensure Win32 long paths are enabled in git. ```bash mkdir %USERPROFILE%\Documents\Arduino\hardware\pico git clone https://github.com/earlephilhower/arduino-pico.git %USERPROFILE%\Documents\Arduino\hardware\pico\rp2040 cd %USERPROFILE%\Documents\Arduino\hardware\pico\rp2040 git submodule update --init --recursive cd tools python .\get.py ``` -------------------------------- ### Install Arduino-Pico via Git Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/install.md Clone the repository and initialize submodules to install the latest development version of the Arduino-Pico core. This method is recommended for users who want to contribute or use pre-release versions. ```bash mkdir -p ~/Arduino/hardware/pico git clone https://github.com/earlephilhower/arduino-pico.git ~/Arduino/hardware/pico/rp2040 cd ~/Arduino/hardware/pico/rp2040 git submodule update --init cd pico-sdk git submodule update --init cd ../tools python3 ./get.py ``` -------------------------------- ### Install Arduino Pico via GIT (Linux/Mac) Source: https://github.com/earlephilhower/arduino-pico/blob/master/README.md Installs the latest development version of the Arduino Pico board support by cloning the repository and updating submodules. Ensure Python 3 is installed. ```bash mkdir -p ~/Arduino/hardware/pico git clone https://github.com/earlephilhower/arduino-pico.git ~/Arduino/hardware/pico/rp2040 cd ~/Arduino/hardware/pico/rp2040 git submodule update --init --recursive cd tools python3 ./get.py ``` -------------------------------- ### begin Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/pwm.md Initializes and starts the PWM Audio device. It can use a previously set sample rate or one provided as an argument. ```APIDOC ## bool begin() ## bool begin(long sampleRate) ### Description Start the PWM Audio device up with the given sample rate, or with the value set using the prior `setFrequency` call. ### Parameters #### Path Parameters - **sampleRate** (long) - Optional - The sample rate in Hz to start the device with. If not provided, the rate set by `setFrequency` is used. ``` -------------------------------- ### Manual Binary Signing Setup Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/ota.md Configure the Update object to use a public key and SHA256 hash verifier for validating binary signatures before installation. This is done by declaring a BearSSL public key, hash object, and signing verifier, then passing them to the Update.installSignature method. ```cpp BearSSL::PublicKey signPubKey( ... key contents ... ); BearSSL::HashSHA256 hash; BearSSL::SigningVerifier sign( &signPubKey ); ... Update.installSignature( &hash, &sign ); ``` -------------------------------- ### Dynamic USB Configuration Example Source: https://context7.com/earlephilhower/arduino-pico/llms.txt Emulate USB keyboard and mouse with runtime reconfiguration of USB descriptors. Ensure the device is disconnected before reconfiguring. ```cpp #include #include #include void setup() { // Customize USB descriptor before connecting USB.disconnect(); USB.setVIDPID(0x1234, 0x5678); USB.setManufacturer("My Company"); USB.setProduct("Pico HID"); USB.connect(); delay(1000); Keyboard.begin(); Mouse.begin(); } void loop() { if (digitalRead(2) == LOW) { // Button pressed Keyboard.print("Hello USB!"); Keyboard.press(KEY_RETURN); Keyboard.release(KEY_RETURN); Mouse.move(10, 0, 0); // Move mouse right 10 px delay(500); } delay(50); } ``` -------------------------------- ### Example platformio.ini for Raspberry Pi Pico Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/platformio.md This example platformio.ini configuration is suitable for a Raspberry Pi Pico with a 0.5MB filesystem. It specifies the core to be used and the filesystem size. ```ini [env:pico] platform = https://github.com/maxgerhardt/platform-raspberrypi.git board = pico framework = arduino ; board can use both Arduino cores -- we select Arduino-Pico here board_build.core = earlephilhower board_build.filesystem_size = 0.5m ``` -------------------------------- ### begin Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/adc.md Starts the ADC input device with a specified sample rate or the rate set by `setFrequency()`. ```APIDOC ## bool begin() ## bool begin(long sampleRate) ### Description Start the ADC input up with the given sample rate, or with the value set using the prior `setFrequency` call. ### Parameters #### Path Parameters - **sampleRate** (long) - Optional - The sampling frequency in Hz. If not provided, the frequency set by `setFrequency()` is used. ``` -------------------------------- ### Joystick.begin() Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/JoystickBLE/docs/api.md Initializes the Joystick library. This function must be called before using any other Joystick library functions to start emulating a USB joystick. ```APIDOC ## Joystick.begin() ### Description Initializes the Joystick library. Must be called before starting to use the Joystick emulation. Use `Joystick.end()` to stop control. ### Syntax ``` Joystick.begin() ``` ### Parameters None. ### Returns None. ### Example ```cpp #include void setup() { pinMode(2, INPUT_PULLUP); } void loop() { // Initialize the Joystick library when button is pressed if (digitalRead(2) == LOW) { Joystick.begin(); } } ``` ``` -------------------------------- ### Joystick.hat() Example Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/Joystick/docs/api.md Shows how to set the hat switch value, including the released/rest position. ```cpp Joystick.hat(-1), // released/rest position ``` -------------------------------- ### Install Arduino-Pico via Arduino CLI Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/install.md Use these commands to add the Arduino-Pico board support to your Arduino CLI installation. This method is suitable for users who prefer command-line operations. ```bash arduino-cli config add board_manager.additional_urls https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json arduino-cli core update-index arduino-cli core install rp2040:rp2040 ``` -------------------------------- ### beginPacket() Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/wifiudp.md Starts recording outgoing UDP packets. You must call this before writing data. ```APIDOC ## beginPacket() ### Description Starts recording outgoing UDP packets. Call this function before writing data to be sent. You can specify the destination IP address and port. ### Method `WiFiUDP.beginPacket(ip, port)` or `WiFiUDP.beginPacket(domain, port)` ### Endpoint N/A (Method Call) ### Parameters #### Path Parameters - **ip** (IPAddress) - The destination IP address. - **domain** (const char*) - The destination domain name. - **port** (int) - The destination port number. ### Response #### Success Response - **success** (int) - Returns 1 if the packet has begun, 0 otherwise. ``` -------------------------------- ### Initialize Joystick Emulation Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/Joystick/docs/api.md Call `Joystick.begin()` before using the library. This example shows initialization triggered by a button press. ```cpp #include void setup() { pinMode(2, INPUT_PULLUP); } void loop() { // Initialize the Joystick library when button is pressed if (digitalRead(2) == LOW) { Joystick.begin(); } } ``` -------------------------------- ### Bluetooth Classic HID Keyboard Example Source: https://context7.com/earlephilhower/arduino-pico/llms.txt Emulate a Bluetooth Classic HID keyboard. Ensure the host device is ready to pair before running. ```cpp #include void setup() { Serial.begin(115200); KeyboardBT.begin("PicoKeyboard"); // Advertise as BT keyboard delay(2000); // Allow host to pair } void loop() { // Type "Hello, World!" once per second KeyboardBT.print("Hello, World!"); KeyboardBT.press(KEY_RETURN); KeyboardBT.release(KEY_RETURN); delay(1000); } ``` -------------------------------- ### Joystick.position() Example Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/Joystick/docs/api.md Demonstrates setting both X and Y axes simultaneously using the Joystick.position() function. If autosending is active, one report is generated. ```cpp Joystick.position(512,512) ``` -------------------------------- ### Joystick.send_now() Example Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/Joystick/docs/api.md Illustrates how to use Joystick.send_now() in conjunction with Joystick.useManualSend() to send a consolidated HID report after updating multiple buttons and axes. ```cpp #include void setup() { pinMode(2, INPUT_PULLUP); Joystick.begin(); //enable manual sending in setup Joystick.useManualSend(true); } void loop() { if (digitalRead(2) == LOW) { // update all buttons, but nothing is sent to the host for(uint8_t i = 1; i<=32; i++) Joystick.button(i,true); Joystick.X(256); Joystick.sliderLeft(0); //now send in one HID report Joystick.send_now(); } } ``` -------------------------------- ### Get BLE Server Object Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/ble.md Obtain a pointer to the global BLE server object using BLE.server(). This object is used to manage services and start advertising. ```APIDOC ## Get BLE Server Object ### Description Get a pointer to the single global BLE server object. This object is used to add services and start advertising. ### Method ```cpp auto server = BLE.server(); ``` ### Parameters None ### Request Example ```cpp #include void setup() { BLE.begin(); auto server = BLE.server(); // Get pointer to single global server object // ... create a BLEService with BLECharacteristics somehow... server->addService(...); // Add the service we just made to the object server->startAdvertising(); // Tell the world about it! } ``` ``` -------------------------------- ### Main Entry Point and Initialization Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/WebServer/examples/FSBrowser/data/edit/index.htm Handles the initial loading of the page, parsing URL parameters, and setting up the file tree and editor components. ```javascript function onBodyLoad(){ var vars = {}; var parts = window.location.href.replace(/\(?:\[?&\\\]+)([^=&]+)=([^&\]+)/gi, function(m,key,value) { vars[key] = value; }); if (typeof ace != "undefined") { var editor = createEditor("editor", vars.file, vars.lang, vars.theme); } tree = createTree("tree", editor); createHeader("header", tree, editor); refreshStatus(); }; if (typeof ace == "undefined") { console.log("Cannot load ace.js from the web, trying local copy"); var script = document.createElement('script'); script.src = "/edit/ace.js"; script.async = false; document.head.appendChild(script); } ``` -------------------------------- ### begin Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/fs.md Mounts the file system. This must be called before any other file system API operations. ```APIDOC ## begin ### Description Mounts the file system. Must be called before any other FS APIs. Returns `true` if successful, `false` otherwise. Note: LittleFS automatically formats the filesystem if one is not detected, which is configurable via `setConfig`. ### Usage ```cpp SDFS.begin(); // or LittleFS.begin(); ``` ``` -------------------------------- ### Initialize SingleFileDrive and Callbacks Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/singlefile.md Include necessary headers, initialize LittleFS, define callbacks for plug, unplug, and delete events, and then begin the SingleFileDrive with the internal and exported filenames. ```cpp #include #include void myPlugCB(uint32_t data) { // Tell my app not to write to flash, we're connected } void myUnplugCB(uint32_t data) { // I can start writing to flash again } void myDeleteDB(uint32_t data) { // Maybe LittleFS.remove("myfile.txt")? or do nothing } void setup() { LittleFS.begin(); singleFileDrive.onPlug(myPlugCB); singleFileDrive.onUnplug(myUnplugCB); singleFileDrive.onDelete(myDeleteCB); singleFileDrive.begin("littlefsfile.csv", "Data Recorder.csv"); // ... rest of setup ... } ``` -------------------------------- ### Initialize Ethernet Connection Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/ethernet.md Replace WiFi.begin() and WiFi.connected() with eth.begin() and eth.connected(). ```cpp void setup() { .... // WiFi.begin(SSID, PASS) eth.begin(); //while (!WiFi.connected()) { while (!eth.connected()) { Serial.print("."); } Serial.print("IP address: "); //Serial.println(WiFi.localIP()); Serial.println(eth.localIP()); .... } ``` -------------------------------- ### EEPROM.begin() Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/eeprom.md Initializes the emulated EEPROM. It copies the EEPROM sector into RAM for faster access and supports sizes from 256 bytes to 4096 bytes. ```APIDOC ## EEPROM.begin(size=256…4096) ### Description Call before the first use of the EEPROM data for read or write. It makes a copy of the emulated EEPROM sector in RAM to allow random update and access. ### Parameters #### Path Parameters - **size** (int) - Optional - The size of the emulated EEPROM in bytes, defaults to 256. Maximum size is 4096. ``` -------------------------------- ### Start ADC Input Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/adc.md Starts the ADC input device with a specified sample rate or the rate previously set by setFrequency(). ```cpp bool begin()/begin(long sampleRate) ``` -------------------------------- ### Start BLE Advertising Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/ble.md Starts broadcasting BLE advertisements so that BLE clients can discover the device. Call this after all services are defined or after modifying services/characteristics. ```APIDOC ## BLE.startAdvertising(bool advertiseServiceUUID) ### Description Starts broadcasting for BLE clients to find the device. Call this after all services are created, or after `BLE.stopAdvertising()` and changing services or characteristics. Without this call, your Pico won’t be discoverable. The Boolean flag `advertiseServiceUUID` controls inclusion of the service UUID in the advertising data. ### Method `BLE.startAdvertising()` ### Parameters #### Path Parameters - **advertiseServiceUUID** (bool) - Required - Controls inclusion of the service UUID in the advertising data. ``` -------------------------------- ### I2S Audio Output Example Source: https://context7.com/earlephilhower/arduino-pico/llms.txt Configure and use PIO-based I2S for digital audio output. This example generates a 440 Hz sine wave. ```cpp #include I2S i2sOut(OUTPUT); void setup() { i2sOut.setBCLK(26); // BCLK on GP26, LRCLK auto on GP27 i2sOut.setDATA(28); // DOUT on GP28 i2sOut.setBitsPerSample(16); i2sOut.setBuffers(4, 64); // 4 DMA buffers × 64 words i2sOut.begin(44100); // 44.1 kHz sample rate } // Generate a 440 Hz sine wave and send to I2S void loop() { static float phase = 0.0f; const float freq = 440.0f; const float sampleRate = 44100.0f; int16_t sample = (int16_t)(32767.0f * sinf(phase)); i2sOut.write16(sample, sample); // Both left and right channels phase += 2.0f * M_PI * freq / sampleRate; if (phase >= 2.0f * M_PI) phase -= 2.0f * M_PI; } ``` -------------------------------- ### PWM Audio Output Example Source: https://context7.com/earlephilhower/arduino-pico/llms.txt Generate analog audio output using RP2040 PWM hardware. This example produces Middle C (261.63 Hz) for stereo channels. ```cpp #include PWMAudio pwm(0, true); // GP0 = left, GP1 = right (stereo) void setup() { pwm.setBuffers(4, 32); pwm.begin(22050); // 22.05 kHz } void loop() { static float phase = 0.0f; const float freq = 261.63f; // Middle C int16_t s = (int16_t)(16383.0f * sinf(phase)); pwm.write(s, true); // Left sample (blocks until space) pwm.write(s, true); // Right sample phase += 2.0f * M_PI * freq / 22050.0f; if (phase >= 2.0f * M_PI) phase -= 2.0f * M_PI; } ``` -------------------------------- ### Reading Raw Characteristic Data Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/ble.md Provides functions to access the raw binary data of a BLE characteristic. Use `valueData()` to get a pointer to the data and `valueLen()` to get its size. ```cpp const void * valueData() size_t valueLen() ``` -------------------------------- ### File Object Operations Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/fs.md Operations specific to the File object returned by `SDFS/LittleFS.open()` and `dir.openFile()`. Includes methods for seeking within a file, getting the current position, retrieving the file size, and getting the file name. ```APIDOC ## File object ### Description `SDFS/LittleFS.open()` and `dir.openFile()` functions return a *File* object. This object supports all the functions of *Stream*, plus specific file operations. ### Methods - **seek(offset, mode)**: Moves the file position. `mode` can be `SeekSet`, `SeekCur`, or `SeekEnd`. Returns true if successful. ```cpp file.seek(offset, mode) ``` - **position()**: Returns the current position inside the file in bytes. ```cpp file.position() ``` - **size()**: Returns the file size in bytes. ```cpp file.size() ``` - **name()**: Returns the short file name as a `const char*`. Convert to `String` for storage. ```cpp String name = file.name(); ``` ``` -------------------------------- ### Wait for Ethernet Connection and Print IP Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/usbethernet.md In the setup() function, wait until the Ethernet connection is established and then print the assigned IP address. This loop will print a dot for each second the connection is pending. ```cpp void setup() { .... eth.begin(); while (!eth.connected()) { Serial.print("."); } Serial.print("IP address: "); Serial.println(eth.localIP()); .... } ``` -------------------------------- ### Mouse.begin() Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/MouseBLE/docs/api.md Begins emulating the mouse connected to a computer. This must be called before any other Mouse library functions that control the computer's cursor or buttons. ```APIDOC ## Mouse.begin() ### Description Begins emulating the mouse connected to a computer. `begin()` must be called before controlling the computer. To end control, use `Mouse.end()`. ### Syntax ``` Mouse.begin() ``` ### Parameters None. ### Returns None. ### Example ```cpp #include void setup() { pinMode(2, INPUT); } void loop() { // Initialize the Mouse library when button is pressed if (digitalRead(2) == HIGH) { Mouse.begin(); } } ``` ### See also * [Mouse.click()](#mouseclick) * [Mouse.end()](#mouseend) * [Mouse.move()](#mousemove) * [Mouse.press()](#mousepress) * [Mouse.release()](#mouserelease) * [Mouse.isPressed()](#mouseispressed) ``` -------------------------------- ### Configure UART Pins and Begin Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/serial.md Configure the RX and TX pins for Serial1 (UART0) before calling begin(). ```cpp Serial1.setRX(pin); Serial1.setTX(pin); Serial1.begin(baud); ``` -------------------------------- ### Get File Size Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/fs.md Returns the total size of an open file in bytes. ```cpp file.size() ``` -------------------------------- ### Mouse.end() Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/Mouse/docs/api.md Stops emulating the mouse connected to a computer. Use `Mouse.begin()` to start control again. ```APIDOC ## Mouse.end() ### Description Stops emulating the mouse connected to a computer. To start control, use `Mouse.begin()`. ### Syntax ``` Mouse.end() ``` ### Parameters None. ### Returns None. ### Example ```cpp #include void setup() { pinMode(2, INPUT); // Initiate the Mouse library Mouse.begin(); } void loop() { // If the button is pressed, send a left mouse click if (digitalRead(2) == HIGH) { Mouse.click(); // Then end the Mouse emulation Mouse.end(); } } ``` ### See also * [Mouse.begin()](#mousebegin) * [Mouse.click()](#mouseclick) * [Mouse.move()](#mousemove) * [Mouse.press()](#mousepress) * [Mouse.release()](#mouserelease) * [Mouse.isPressed()](#mouseispressed) ``` -------------------------------- ### Enable USB Serial Port and Upload Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/usb.md Manually call Serial.begin() in setup() to enable the USB serial port and automatic sketch upload. Failure to do so requires manual upload mode. ```cpp Serial.begin(115200); ``` -------------------------------- ### NTP.begin(s1) Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/wifintp.md Initializes the NTP client to use one or two specified NTP servers. This is essential for synchronizing the Pico's internal clock with internet time. ```APIDOC ## NTP.begin(s1) ### Description Initializes the NTP client to use one or two specified NTP servers. This is essential for synchronizing the Pico's internal clock with internet time. ### Parameters #### Path Parameters - **s1** (string or IPAddress) - Required - The primary NTP server address. - **s2** (string or IPAddress) - Optional - A secondary NTP server address. ### Request Example ```cpp NTP.begin("pool.ntp.org", "time.nist.gov"); ``` ``` -------------------------------- ### I2S Control Methods Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/i2s.md Methods to start, stop, and manage the I2S data stream. ```APIDOC ## bool begin()/begin(long sampleRate) Start the I2S device up with the given sample rate, or with the value set using the prior `setFrequency` call. ## void end() Stops the I2S device. ## void flush() Waits until all the I2S buffers have been output. ## void getOverUnderflow() Returns a flag indicating if the I2S system ran our of data to send on output, or had to throw away data on input. ## void getOverflow() Returns a flag indicating if the I2S system had to throw away data on input. ## void getUnderflow() Returns a flag indicating if the I2S system ran our of data to send on output. ``` -------------------------------- ### remotePort() Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/wifiudp.md Gets the port number of the remote host that sent the current UDP packet. ```APIDOC ## remotePort() ### Description Gets the port number of the remote host from which the current UDP packet was received. ### Method `WiFiUDP.remotePort()` ### Endpoint N/A (Method Call) ### Parameters None ### Response #### Success Response - **remotePortNumber** (int) - The port number of the remote host. ``` -------------------------------- ### BLE Initialization Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/ble.md Starts the BLE stack on the Pico. This must be called before setting up any services or client operations. The `name` parameter is used for advertising the device. ```APIDOC ## BLE.begin(String name) ### Description Starts the BLE stack on the Pico. Call this before setting up any services or client operations. The `name` is used when advertising the device. ### Method `BLE.begin()` ### Parameters #### Path Parameters - **name** (String) - Required - The name to be used when advertising the device. ``` -------------------------------- ### remoteIP() Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/wifiudp.md Gets the IP address of the remote host that sent the current UDP packet. ```APIDOC ## remoteIP() ### Description Gets the IP address of the remote host from which the current UDP packet was received. ### Method `WiFiUDP.remoteIP()` ### Endpoint N/A (Method Call) ### Parameters None ### Response #### Success Response - **remoteIpAddress** (IPAddress) - The IP address of the remote host. ``` -------------------------------- ### WiFiServer Constructor Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/wifiserver.md Initializes a WiFiServer object. This is the entry point for creating a server instance. ```APIDOC ## WiFiServer() ### Description Constructs a WiFiServer object. ### Method Constructor ### Endpoint N/A ### Parameters None explicitly documented for constructor signature. ### Request Example ```cpp WiFiServer server(80); ``` ### Response N/A ``` -------------------------------- ### setFrequency Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/adc.md Sets the ADC sampling frequency. Does not start recording but affects subsequent `begin()` calls. ```APIDOC ## bool setFrequency(long sampleRate) ### Description Sets the ADC sampling frequency, but does not start recording (however if the device was already running, it will continue to run at the new frequency). Note that every pin requested will be sampled at this frequency, one after the other. ### Parameters #### Path Parameters - **sampleRate** (long) - Required - The desired sampling frequency in Hz. ``` -------------------------------- ### List Supported Boards via Arduino CLI Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/install.md After installing the core, you can use this command to list all supported boards for the rp2040 platform via the Arduino CLI. ```bash arduino-cli board listall | grep rp2040 ``` -------------------------------- ### Get SerialUSB RTS State Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/serial.md Retrieve the current state of the RTS virtual line for SerialUSB. ```cpp bool rtsState = Serial.rts(); ``` -------------------------------- ### Get SerialUSB DTR State Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/serial.md Retrieve the current state of the DTR virtual line for SerialUSB. ```cpp bool dtrState = Serial.dtr(); ``` -------------------------------- ### Stop Mouse Emulation Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/MouseBLE/docs/api.md Stops emulating the mouse connected to a computer. Use `Mouse.begin()` to start control. ```cpp #include void setup() { pinMode(2, INPUT); // Initiate the Mouse library Mouse.begin(); } void loop() { // If the button is pressed, send a left mouse click if (digitalRead(2) == HIGH) { Mouse.click(); // Then end the Mouse emulation Mouse.end(); } } ``` -------------------------------- ### Configure Filesystem Parameters Source: https://github.com/earlephilhower/arduino-pico/blob/master/docs/fs.md Configure specific parameters for LittleFS, SDFS, and FatFS using their respective Config objects before mounting. Default configurations are used if setConfig is not called. ```cpp LittleFSConfig cfg; cfg.setAutoFormat(false); LittleFS.setConfig(cfg); SDFSConfig c2; c2.setCSPin(12); SDFS.setConfig(c2); FatFSConfig c3; c3.setUseFTL(false); // Directly access flash memory c3.setDirEntries(256); // We need 256 root directory entries on a format() c3.setFATCopies(1); // Only 1 FAT to save 4K of space and extra writes FatFS.setConfig(c3); FatFS.format(); // Format using these settings, erasing everything ``` -------------------------------- ### Initialize Mouse Emulation Source: https://github.com/earlephilhower/arduino-pico/blob/master/libraries/MouseBLE/docs/api.md Call `Mouse.begin()` before controlling the computer's mouse. Use `Mouse.end()` to stop emulation. ```cpp #include void setup() { pinMode(2, INPUT); } void loop() { // Initialize the Mouse library when button is pressed if (digitalRead(2) == HIGH) { Mouse.begin(); } } ```