# Blink example code for Cobble board in CircuitPython (https://cobble.tinkerfarm.net/). # Code by Bill Ball + AI. CC BY. import time # Import the time module to handle delays and pauses. import board # Import the board module to access the hardware pin definitions. import digitalio # Import the digitalio module to control standard digital pins. import neopixel # Import the neopixel library to send the proper RGB off signal. # Note that CircuitPython shortens GPIO to IO. led = digitalio.DigitalInOut(board.IO48) # Initialize GPIO48 as a digital pin object. # the text after the period in the led object identifies the attribute to change. led.direction = digitalio.Direction.OUTPUT # Set the pin direction to output so it can send power. for i in range(10): # Start a loop that will repeat the indented block of code 10 times. # range will execute its values from 0 through 9. led.value = True # Turn the red LED on by setting the pin voltage high. # the text after the period in the time module executes the sleep function with a value of 1 second. time.sleep(1.0) # Pause the program for 1 second while the LED stays on. led.value = False # Turn the red LED off by setting the pin voltage low. time.sleep(1.0) # Pause the program for 1 second while the LED stays off. led.deinit() # Release the GPIO48 pin resource once the 10 blinks are finished. # the following code is needed because the LED shares a pin with the Neopixel. pixel = neopixel.NeoPixel(board.IO48, 1) # Initialize GPIO48 as a 1-pixel NeoPixel object. pixel.fill((0, 0, 0)) # Send the official WS2812 data signal to turn all RGB channels off.