This circuit consists of a Raspberry Pi Pico microcontroller unit (MCU) interfaced with two LEDs: one green and one red. The Raspberry Pi Pico is responsible for controlling the state (on/off) of the LEDs through its GPIO pins. The green LED is connected to one of the GPIO pins of the Raspberry Pi Pico, and similarly, the red LED is connected to another GPIO pin. The circuit is designed to demonstrate basic GPIO control using the Raspberry Pi Pico.
The following code is intended for the Raspberry Pi Pico microcontroller to control the LEDs. The code is written in C/C++ for the Arduino environment (.ino
file).
void setup() {
// Initialize the digital pin as an output for the red LED.
pinMode(19, OUTPUT);
// Initialize the digital pin as an output for the green LED.
pinMode(20, OUTPUT);
}
void loop() {
// Turn on the red LED.
digitalWrite(19, HIGH);
delay(1000); // Wait for a second.
// Turn off the red LED.
digitalWrite(19, LOW);
// Turn on the green LED.
digitalWrite(20, HIGH);
delay(1000); // Wait for a second.
// Turn off the green LED.
digitalWrite(20, LOW);
}
This code sets up the Raspberry Pi Pico to alternate between turning the red and green LEDs on and off every second. The pinMode
function is used to configure the pins connected to the LEDs as outputs, and the digitalWrite
function is used to set the pins high (turn on the LED) or low (turn off the LED). The delay
function is used to create a one-second interval between LED state changes.