# 1 - Blink

### Video

{% embed url="<https://youtu.be/r4IVEBA3ov0>" %}

### Code with Detailed Comments

```python
'''
Pico Slice 1 - RGB Mixer
Tutorial 1 - Blink
'''

# CircuitPython comes with a bunch of modules
# that makes programming microcontrollers easy!
# To get started, we're going to blink our red LED.

# First we import the modules we're going to use in our code

import time
import board
from digitalio import DigitalInOut, Direction, Pull

# To control our red LED, we need to create it in code as a DigitalInOut object.
# When we do, we specify which I/O pin to connect to.
# The board module we imported makes this really easy!
# If you check your Pico Slice, you'll see GP2 labeling the red LED,
# that's what you need to tell the board module to connect to the red LED!

red_led = DigitalInOut(board.GP2)

# red_led is now a DigitalInOut object with built-in attributes and functionality!
# By default, its pin direction attribute is set to input, but we'll have to change it
# to output in order to drive the LED.
# Naturally there's a built in method for doing so!

red_led.switch_to_output()

# Now that that it's an output, we can simply turn it on and off!
# Let's set up an endless while loop and to do that continuously.


while True:                     # Loop Forever:
    red_led.value = True            # Turn the red LED on
    time.sleep(0.5)                 # Do nothing for 0.5 seconds
    red_led.value = False           # Turn the red LED off
    time.sleep(0.5)                 # Do nothing for 0.5 seconds



```

### Just Code

```python
'''
Pico Slice 1 - RGB Mixer
Tutorial 1 - Blink
'''

import time
import board
from digitalio import DigitalInOut, Direction, Pull

red_led = DigitalInOut(board.GP2)
red_led.switch_to_output()

while True:
    red_led.value = True
    time.sleep(0.5)
    red_led.value = False
    time.sleep(0.5)



```

{% embed url="<https://twitter.com/breadstick_kits/status/1581855148636516353?s=20&t=muiqVzlVZwA9aPx9FlO8tQ>" %}
Blink in action
{% endembed %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.breadstick.ca/breadstick/pico-slices/slice-1-led-mixer/circuitpython-code/1-blink.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
