Scan the I2C bus for devices and display results. Show how to directly access the hardware integer dividers, in case AEABI injection is disabled. See also: blink, blinking an LED attached to a GPIO.
Use GPIO to bitbang the serial protocol for a DHT temperature/humidity sensor. Register an interrupt handler to run when a GPIO is toggled. Use the GPIOs to drive a seven segment LED display.
Stream data using the XIP stream hardware, which allows data to be DMA'd in the background whilst executing code from flash.ĭMA directly from the flash interface (continuous SCK clocking) for maximum bulk read performance. A useful utility to drag and drop onto your Pico if the need arises.Įrase a flash sector, program one flash page, and read back the data. An example of a NO_FLASH binary (UF2 loaded directly into SRAM and runs in-place there). Show how they are affected by different types of flash reads. Read and clear the cache performance counters. Use an IRQ handler to reconfigure a DMA channel, in order to continuously drive data through a PIO state machine. Use the general purpose clock outputs (GPOUT) to drive divisions of internal clocks onto GPIO outputs.Įnable the clock resuscitate feature, "accidentally" stop the system clock, and show how we recover.īuilds two version of the same app with different configurationsīuild a control block list, to program a longer sequence of DMA transfers to the UART. Read analog values from a microphone and plot the measured sound amplitude.Ĭhange the system clock frequency to 48 MHz while running. Includes example of free-running capture mode. The obligatory Hello World program for Pico (Output over USB version)ĭisplay a Joystick X/Y input based on two ADC inputs.Īn interactive shell for playing with the ADC. The obligatory Hello World program for Pico (Output over serial version) See Getting Started with the Raspberry Pi Pico and the README in the pico-sdk for information ReadAnalogVoltage - Reads an analog input and prints the voltage to the serial monitor.Raspberry Pi Pico SDK Examples Getting started
Once you've understood this example, check out the DigitalReadSerial example to learn how read a switch connected to the board.ĪnalogReadSerial - Read a potentiometer, print its state out to the Arduino Serial Monitor.īareMinimum - The bare minimum of code needed to start an Arduino sketch.ĭigitalReadSerial - Read a switch, print the state out to the Arduino Serial Monitor.įade - Demonstrates the use of analog output to fade an LED. Once you've understood the basic examples, check out the BlinkWithoutDelay example to learn how to create a delay while doing other things. When you use the delay() command, nothing else happens for that amount of time. In between the on and the off, you want enough time for a person to see the change, so the delay() commands tell the board to do nothing for 1000 milliseconds, or one second. That takes the LED_BUILTIN pin back to 0 volts, and turns the LED off. That creates a voltage difference across the pins of the LED, and lights it up. In the main loop, you turn the LED on with the line: The first thing you do is to initialize LED_BUILTIN pin as an output pin with the line You may also load it from the menu File/Examples/01.Basics/Blink.
The value of the resistor in series with the LED may be of a different value than 220 ohm the LED will lit up also with values up to 1K ohm.Īfter you build the circuit plug your Arduino board into your computer, start the Arduino Software (IDE) and enter the code below. In the diagram below we show an UNO board that has D13 as the LED_BUILTIN value. Connect the short leg of the LED (the negative leg, called the cathode) to the GND. Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor. If you want to lit an external LED with this sketch, you need to build this circuit, where you connect one end of the resistor to the digital pin correspondent to the LED_BUILTIN constant. Here is the correspondence between the constant and the digital pin. This constant is LED_BUILTIN and allows you to control the built-in LED easily. To make your life easier, we have a constant that is specified in every board descriptor file. This LED is connected to a digital pin and its number may vary from board type to board type. This example uses the built-in LED that most Arduino boards have. This example shows the simplest thing you can do with an Arduino to see physical output: it blinks the on-board LED.