SINGLE LED BLINK

 

πŸ’‘ LED Interface with RP2040 – Short Note

Overview:

An LED (Light Emitting Diode) is a basic output device used with RP2040 to visually indicate status, signals, or logic. It glows when current flows through it in the forward direction.

βš™οΈ Required Components:

  • R2040 (or any board)

  • LED (any color)

  • 220Ξ© resistor (to limit current)

  • Breadboard and jumper wires

πŸ”Œ Circuit Diagram:

 

 

πŸ“ Notes:

    • Pin(2, Pin.OUT) sets GPIO2 as an output pin.

    • led.toggle() is a convenient way to flip the state without checking it first.

    • You can replace 2 with any valid GPIO pin like 3, 15, etc., depending on your wiring.

βœ… Wokwi Setup Steps

  1. Go to Wokwi: https://wokwi.com

  2. Click “New Project” β†’ Select Raspberry Pi Pico (Python)

πŸ”Œ Connect LED in Simulator

In Wokwi circuit editor, connect as follows:

  • GPIO2 β†’ Anode (+) of LED (with 220Ξ© resistor)

  • Cathode (–) of LED β†’ GND

 

πŸ› οΈ Customizing the Simulation

If you’d like to modify the GPIO pin or adjust the blink interval:

  1. Click the “Edit Code” button in the simulation.

  2. Change the Pin(5, Pin.OUT) line to use your desired GPIO pin (e.g., Pin(2, Pin.OUT)).

  3. Adjust the sleep(0.5) value to set a different blink interval (e.g., sleep(1) for a 1-second interval).

  4. Click the “Start Simulation” button to see the changes in action.

πŸ“ SampleΒ  Code:

from machine import Pin
import time

# Initialize LED on GPIO2 (or change to GPIO3 if needed)
led = Pin(2, Pin.OUT)

# Loop to toggle LED every second
while True:
led.toggle() # Toggle the LED state (ON to OFF or vice versa)
time.sleep(1) # Wait for 1 second

🧠 Key Points:

  • Always use a resistor to prevent LED damage.

  • led.toggle() turns ON the LED.

  • LEDs are polarity sensitive (must be connected the right way).

  • Multiple LEDs can be connected to different pins for patterns.

 

πŸ“ž For More Details & Project Support:

Power Integrated Solutions
Networks | Electronics | Home Automation | Water Automation | IoT | PLC | Embedded | DBMS

πŸ“ Location:
10A/3, Radhakrishnan Colony,
Sasthri Road, Tennur,
Tiruchirappalli, Tamil Nadu – 620017


πŸ“ View on Google Maps

πŸ“§ Email:

πŸ“± Phone / WhatsApp:
+91 76393 85448
+91 82488 85959

🌐 Let’s Build the Future with Innovation in Education & Technology!